Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 CPU 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,

like image 690
dude Avatar asked Jan 22 '23 03:01

dude


1 Answers

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.

like image 170
Tamás Avatar answered Feb 02 '23 09:02

Tamás