book
Article ID: KB0085894
calendar_today
Updated On:
Description
Resolution:
The computational approach of "% CPU" is different for "top", "ps" and the Hawk process.getProcess method.
top % CPU:
The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment, if 'Irix mode' is Off, top will operate in 'Solaris mode' where a task's cpu usage will be divided by the total number of CPUs. You toggle 'Irix/Solaris' modes with the 'I' interactive command.
ps % CPU:
CPU utilization of the process in "##.#" format. Currently, it is the CPU time used divided by the time the process has been running (cputime/realtime ratio), expressed as a percentage. It will not add up to 100% unless you are lucky. (alias pcpu).
Hawk Process.getProcess() % CPU:
The ratio of CPU time used recently to CPU time available in the same period. The meaning of "recently" in this context is unspecified. The CPU time available is determined in an unspecified manner.
The computation of Hawk % CPU is similar to ps but in ps the CPU time used, is the time since the process is running, whereas in Hawk its since the previous method call is made. So in case of method subscription the CPU time used to compute % CPU will be the subscription interval. In top, the % CPU is dependent on number of CPUs, whereas Hawk % CPU is independent of the number of CPUs.
As the computation approach and parameters are different, the output of Hawk % CPU can not be equal to ps or top.
Issue/Introduction
Why are the results of % CPU used from Hawk’s Process:getProcess() method are not consistent with both "top" and "ps" commands?