

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer

Hey, I'm totally behind this topic.

Yesterday I was doing profiling 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?


share|improve this question
up vote 5 down vote accepted

A CPU-second is one second of time on a CPU.

Process execution time has two measurements:

  • CPU time, or the amount of time that the CPU spent actively running the process; and
  • Wall time, or the amount of time that passes between you starting the process and the process ending.

Assuming a single CPU core, they are related as so:

(Wall time) - (CPU time) = (time the CPU spent doing other things)

So in a simple example, if you run a process and it takes 10 seconds but you get a measurement of 7 CPU-seconds, then during that 10 seconds the CPU spent 3 seconds doing things other than execute your process.

CPU time is generally split into two types:

  • "sys" or "kernel" time, or time that the kernel spent doing things on your process' behalf -- running I/O, timers, mutex's, whatever
  • "user" time, or execution run by a process in user space

So for example:

$ time sleep 1

real    0m1.005s
user    0m0.000s
sys     0m0.002s

In this case, we are sleeping for one second. The system spent 2/1000 seconds in kernel space, probably setting up timers and interrupts for us, no time in user space, and the whole thing took 1.005 seconds to run, which means that during that time period the computer spent an additional 0.003 seconds doing things other than dealing with our process.

Off the top of my head I don't know how or why you'd get an apparently negative number for CPU time.

share|improve this answer


I saw something bizzare with negative cpu times a few years back under AMD dual core CPUs. There was a processer driver update that fixed the issue. Basicaly the timing between the 2 processors drifted and caused issues like negative cpu times and negative ping times.

share|improve this answer

A "CPU second" is a second's worth of CPU cycles running the process or thread. You can convert it to wall time by dividing it by the CPU usage:

15 CPU seconds / 50% CPU usage = 30 wall seconds

Negative CPU times are a glitch in the measurement process, possibly an overflow.

share|improve this answer
Note that since, with many CPUs, clock rates will vary with load (and mains vs. battery), so it isn't a precise measurement. – Richard May 5 '10 at 8:49
@Ignacio Do you mean: actual second of processing time assigned for this process? – dude May 5 '10 at 9:08
@Richard are you mentioning the equation above? – dude May 5 '10 at 9:09
@dude: no. More than the number of cycles a processor (and thus the number of instructions executed) will vary depending on environmental factors. And depending how many cache misses (which I forgot in the last answer) there could be a huge difference in the amount of work: cache misses (causing the processor to idle) can dominate the time. – Richard May 6 '10 at 11:40

Your Answer


