如何在python中计算程序运行时间?
如何在python中计算程序运行时间?
-
您可能需要看一下该
timeit
模块:http://docs.python.org/library/timeit.html
或
profile
模块:http://docs.python.org/library/profile.html
这里还有一些不错的教程:
http://www.doughellmann.com/PyMOTW/profile/index.html
http://www.doughellmann.com/PyMOTW/timeit/index.html
而且该
time
模块也可能派上用场,尽管我更喜欢后两项关于基准测试和性能分析代码性能的建议: