There are two very useful for timing the magic command: %% time and% timeit if you have some code that runs to very slow, and you want to determine whether the problem lies here, these two commands will be very convenient.
1. %% time will give a time code running cell once it takes.
Time %%
Import Time
for _ in Range (1000):
the time.sleep (0.01) for 0.01 seconds The SLEEP #
Output:
the CPU Times: User MS 196, SYS: 21.4 MS, Total: 217 MS
Wall Time: S 11.6
2.% time will be given time to run the current code line once it takes.
numpy Import
% Time numpy.random.normal (size = 1000)
the Output:
Wall Time: 1E + 03 [mu] S
3.% timeit use Python's timeit module, it will execute a statement 100,000 (default), then It gives the fastest run three times the average.
numpy Import
% the timeit numpy.random.normal (size = 100)
Output:
12.8 ± 1.25 [mu] S [mu] S per Loop (dev Mean ± STD. 7 of the runs, each Loops 100000..)
----------------------- ---------
author: sirloin face
source: CSDN
original: https: //blog.csdn.net/shuibuzhaodeshiren/article/details/86650688
copyright: This article is a blogger original article, reproduced, please attach Bowen link!