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 ============================================================== 1
def test(num): 2 11 45.0 4.1 0.2 for i in range(num): 3 10 7493.0 749.3 36.3
print(num) 4 10 6816.0 681.6 33.1 print(str(num)) 5 10 6263.0 626.3 30.4
print(num*2) 6 1 1.0 1.0 0.0 return 0
 

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:[email protected]
QQ群:637538335
关注微信