你如何计算python中的程序运行时间? [英] How do you calculate program run time in 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
模块也可能会派上用场,尽管我更喜欢后面两个关于基准测试和代码性能分析的建议:
http://docs.python.org/library/time.html
How do you calculate program run time in python?
You might want to take a look at the timeit
module:
http://docs.python.org/library/timeit.html
or the profile
module:
http://docs.python.org/library/profile.html
There are some additionally some nice tutorials here:
http://www.doughellmann.com/PyMOTW/profile/index.html
http://www.doughellmann.com/PyMOTW/timeit/index.html
And the time
module also might come in handy, although I prefer the later two recommendations for benchmarking and profiling code performance:
http://docs.python.org/library/time.html
这篇关于你如何计算python中的程序运行时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!