Humble CPU Monitor

Print Friendly, PDF & Email

As a developer, one of the many concerns I have when I write and test software is “how much CPU does this thing use?” – and in Windows there are some ways to keep an eye on this, depending on the level of details you’re interested in.

For example, the GetProcessTimes function is useful to get the amount of time the process has executed in Kernel and User mode – two subsequent snapshots can be used to determine the CPU% used by that process:

\(CPU\% = \frac{(K_{t_2}+U_{t_2})-(K_{t_1}+U_{t_1})}{t_2-t_1}\)

If we are interested in the total CPU usage (that is, all the time spent in all cores, normalised to 1), we can instead use the Performance Counters and retrieve the “Processor(_Total)\% Processor Time“. It is also possible to get the Kernel and User time for each thread of the process but this would require much more coding.

There are various incredible software around to have a detailed view of each process in the machine and to get the CPU/GPU usage, disk I/O and so on and so forth: not only the good, old Task Manager (which is getting better and better in Windows 10), but also the Sysinternals Process Explorer or Process Hacker.

Nevertheless, sometime, I got to need a very simple application able to show me the total amount of CPU used and possibly a short history of it, both on my laptop or on the desktop PC (I noticed that sometimes Process Explorer and Process Hacker can drain a bit of CPU…); so I decided to implement a humble version of such a tool (in C#) and it can be found on GitHub here.

CPU history and instant value
CPU% and bar color

It simply shows an icon in the Tray Bar which changes with the CPU being used and through a contextual menu it is possible to show a window that shows a bar with a different height and colour depending on the instant CPU usage, so to have a bit of “history” of it.

Also, it is possible to query every single CPU usage and split the history chart in separate charts, one for each core.

Humble CPU Monitor: splitted CPUs

Finally, through the “Select process” menu item, it is possible to list all the processes to which the user has access and select one of them to be plotted on an independent chart:

Leave a Reply

Your email address will not be published. Required fields are marked *