%timeit的使用

Posted wqbin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了%timeit的使用相关的知识,希望对你有一定的参考价值。

 

%timeit

 

# Insert 100,000 values at the front of the list (index=0)
c0 = []
t_insert = %timeit -o -n1000 -r100 c0.insert(0, a)
# Append 100,000 values at the end of the list
c1 = []
t_append = %timeit -o -n1000 -r100 c1.append(a)

 

技术图片

以上是关于%timeit的使用的主要内容,如果未能解决你的问题,请参考以下文章

在python中导入timeit.timeit变量

测试代码执行时间的模块-timeit

如何使用timeit模块

测量运行时python中每行花费的时间

Python timeit模块的使用

Python timeit