你如何计算python中的程序运行时间? [英] How do you calculate program run time in python?

查看:66
本文介绍了你如何计算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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆