Thursday, October 20, 2011

Why do the CPU stats vary with ps and top?


The commands ps and top express CPU time differently. While ps calculates it by “total CPU time” divided by “time task is running”, top shows the value as a percentage of overall CPU time.

For ps, this means that the longer a process is running without a high CPU utilization the smaller the value of%cpugets (it converges to zero).

For top, this means that it displays this value as share of the CPU time since last screen update and is therefore more accurate in terms of “current CPU utilization”.