3

I noticed a difference in CPU percentage between two utility:
top and gnome-sytem-monitor (but the same happens with htop...)

The screenshot shows the issue.

You can see as first item both is the process gnome-shell but on the left, top shows/measures a 70% while on the right gnome-system-monitor shows 16%, that's a huge difference.

Why? Is it a bug or simply a different method of measures?


enter image description here


  • 1
    What is value of update interval in seconds under preferences->processes->Behavior section? – sai sasanka Apr 2 at 11:09
  • @saisasanka it's 1 second – mattia.b89 Apr 2 at 21:10
  • So try seeing if the results, by modifying delay of the top command. – sai sasanka Apr 3 at 2:35
  • No, it (top -d 1) doesn't work; nothing changes... – mattia.b89 Apr 3 at 8:26
  • Does Nothing changes mean , you still see the behavior mentioned in the question? But I see a clear difference in my system, seeing both side-by-side after changing refresh time for both top and gnmoe-system-monitor . Also enable CPU Time in gnome-system-monitor tool to get an idea of time at which stat is being collected. This field is displayed by default in top. Perhaps you could also sort the data displayed in descending order of %cpu in both the tools. – sai sasanka Apr 3 at 8:57
1

I see not much differences between these two commands. Both top and gnome-sytem-monitor give per core %cpu utilization. (Here % can be greater than 100) The difference that you see can be attributed to the time interval at which both these commands are collecting the stats.

So please change update interval in seconds under preferences->processes->Behavior section to 1.00 in gnome-sytem-monitor.

Also do the same for top because by default it refreshes every 3.00 seconds. Hit the top -p <pid> command and press d to set the Change delay from 3.00 to: 1.00s and hit enter. Now I don't see much difference at all.

enter image description here You can see the same in the screenshot above. [ Observe that even now there might be a difference in %cpu stat because of difference in seconds part of time at which the utility is collecting the stat ]

0

Issue solved!

enter image description here

top shows per-core CPU usage, thus the sum of percentage will be greater than 100.

While gnome-system-monitor is able to show both per-core and per-CPU. Indeed there is an option (underlined in the screenshot above) that can switch the behaviour.


Systems (usually) have 1 CPU with multiple cores.
In my case, I have 1 CPU with 4 cores. The screenshot shows a CPU stress utility (stress) running on just one core -- one core busy. As you can see, top shows thestress process at 100% and other processes, that is sum will be greater than 100. On the other hand gnome-system-monitor with the underlined option enabled, shows the same stress process at 25% (exactly one forth of top usage).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.