Here, I introduce 2 magic functions which could only be operated in ipython console:
The first is %timeit
%timeit 100**3
Output[1]: 22.7 ns ± 0.897 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
The second is %lprun
If you desire to utilize '%lprun' magic function to time your codes, you need to install line_profiler in advance.
try:
conda install line_profiler
then, you should do 2 steps as following:
%load_ext line_profiler
%lprun -f function function(para)
Now, let's test:
def test(num):
for i in range(num):
print(num)
print(str(num))
print(num*2)
return 0
%lprun -f test test(10)
Output [1]:
Line # Hits Time Per Hit % Time Line Contents
=========&#