【发布时间】:2012-03-20 22:47:01
【问题描述】:
使用 python 内置分析器和在一个处理器中运行的脚本(并且没有多线程)
time python -m cProfile myscript.py
分析器报告的 CPU 时间是 345.710 CPU 秒
24184348 function calls (24183732 primitive calls) in 345.710 CPU seconds
而real、user和sys时间分别是:
real 5m45.926s
user 1m59.340s
sys 0m39.452s
如您所见,CPU 时间几乎是实时的 (345.710 = 5m45.710s)。
那么,鉴于该结果,是否可以假设分析器报告的 CPU 时间包括其他进程使用的时间片和进程阻塞的时间?即探查器 CPU 时间不是进程时间(用户+系统),而是挂钟时间,如在 What do 'real', 'user' and 'sys' mean in the output of time(1)?
提前非常感谢
【问题讨论】:
-
如果您在运行另一个 CPU 密集型任务的情况下运行此计时,数字是否仍然匹配?
-
忽略 - 误解了问题
标签: python time profiling profiler cprofile