views:

196

answers:

2

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,

+1  A: 

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...

wump
"A CPU second is one second that your process is actually scheduled on the CPU." I didn't get that...
dude
As you are running a multitasked operating system, the operating system distributes execution time on CPU cores over all running processes (and threads). This means that each process is running running a part of the time.I suggest that you read something about CPU scheduling, such as http://en.wikipedia.org/wiki/Scheduling_%28computing%29
wump
I think I got you, you mean the actual time the process is taking from the CPU power. I still don't know how I got negative number. I believe it's a bug in Python profiler.
dude
whilst it may be a bug in the profiler, it is much more likely that you are doing something wrong. Remember that most of the time 'select isn't broken' http://www.pragprog.com/the-pragmatic-programmer/extracts/tips.
Sam Holder
+6  A: 

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.

Tamás
Well that's great answer, Thanks!
dude