【发布时间】:2011-07-28 23:39:12
【问题描述】:
我需要获取我的 python 应用程序的 CPU 运行时间。
How to measure execution time of command in windows command line?
我早些时候遇到了上述线程并了解了timeit。但是,根据下载网站,timeit 在 64 位 Windows 中是不支持的。
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=17657#top
time.clock() 在 Windows 中不提供 CPU 时间。
有没有简单的方法来获取我的 python 应用程序的 CPU 时间?
【问题讨论】:
-
目的是什么?您真的需要 CPU 时间还是只想知道需要多长时间?有内置的 Python 工具,例如
timeit和cProfile模块,可以为您做到这一点。 -
我需要 CPU 时间来测试两个独立程序的性能。你知道哪个模块可以报告进程时间吗?我知道 time.clock() 在 Unix 中给出了 CPU 时间,但在 Windows 中没有。
标签: python windows-7 benchmarking