Main Site Documentation

CPU Usage monitor. Works great


#1

I thought i’d share this excellent snippet from Inquisitor over on the Netduino forums. I have been using this for a couple of months now to track my CPU load and it works perfectly.


#2

Clever way to use ticks… Thanks


#3

Unfortunately, does not work correctly with CDC (https://www.ghielectronics.com/community/codeshare/entry/517), you will always get 100% CPU load even if nothing else is running.
This line ruins all the fun:


#4

Not sure how the project works you have linked to.
But if it has a loop without any sleep or wait for external event, then of course, the CPU load is 100% then.


#5

It is in a separate thread, but that line does not return until you send some data.

I have tried that CPUUsage class along with CDC class and my GUI class which is CPU power hungry. GUI works perfectly well, without any lag, I wouldn’t expect that when CPU is 100% loaded. So I have removed GUI class and tried it again it was still showing 100% CPU load.


#6

Does the …

PowerState.WaitForIdleCPU(1, int.MaxValue);

…line return?


#7

It seems that not.


#8

I have noticed that while this monitor works it does seem to prevent the MCU dropping into its propped low power idle state so it will have an impact on current draw.


#9

I usually activate it only for Debugging/profiling sessions.
Then I remove it again