I have an Embedded Linux(Kernel 2.6.37) running on ARM. There's a default top from busybox 1.13.2. And I build a procps-ng 3.3.11 via cross compile to run on this Linux. I found that the process's %cpu via top output from busybox and procps-ng are different.
For example, the %cpu of one process, procps-ng top display about 30%, but busybox top display only about 10%. The total %cpu from procps-ng top and busybox top are the same.
Then I read the calculation source code of busybox and procps-ng. I found that they really have different calculation formula for one process's %cpu.
- busybox top:
CPU% = s->pcpu/sum(s->pcpu) * busy_cpu_ticks/total_cpu_ticks
(pcpu is delta of sys+user time between samples)
- procps-ng top:
CPU% = s->pcpu/total_cpu_ticks
Why the two projects choose different calculation formula? Do they designed for different application case? Thanks!
Have discussed this issue with the procps-ng team, and here's the key point:
Please refer the discussion link for more details:
discussion: different process's %cpu output via top from busybox and procps-ng