开发者

Python profiler and CPU seconds

Hey, I'm totally behind this topic.

Yesterday I was doing profiling using Python profiler module for some script I'm working on, and the unit for time spent was a 'CPU second'. Can anyone remind me with the definition of it?

For example for some profiling I got: 200.750 CP开发者_开发知识库U seconds. What does that supposed to mean? At other case and for time consuming process I got: -347.977 CPU seconds, a negative number!

Is there anyway I can convert that time, to calendar time?

Cheers,


Roughly speaking, a CPU time of, say, 200.75 seconds means that if only one processor worked on the task and that processor were working on it all the time, it would have taken 200.75 seconds. CPU time can be contrasted with wall clock time, which means the actual time elapsed from the start of the task to the end of the task on a clock hanging on the wall of your room.

The two are not interchangeable and there is no way to convert one to the other unless you know exactly how your task was scheduled and distributed among the CPU cores of your system. The CPU time can be less than the wall clock time if the task was distributed among multiple CPU cores, and it can be more if the system was under a heavy load and your task was interrupted temporarily by other tasks.


A CPU second is one second that your process is actually scheduled on the CPU. It can be significantly smaller than than the elapsed real time in case of a busy system, and it can be higher in case of your process running on multiple cores (if the count is per-process, not per-thread). It should never be negative, though...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜