# Calculating processor utilisation

I'm using a Cortex M3 processor on an LPC1769 board. For this particular situation, all processes occur within interrupts. Therefore, within the main "loop" there isn't actually anything to be processed. I want to calculate the processor utilisation however I'm not entirely sure of the best method to do this.

My original idea was to have a variable that is incremented every clock cycle where an interrupt isn't run. I can then use the equation below once a second.

$$processorUtilisation = \frac{totalExpectedTickets - countedTicks}{totalExpectedTickets} * 100$$

However, I'm not entirely sure whether that is a suitable solution mainly because I can't see a way to have a variable increment on every clock cycle.

Any other suggestions?

The tick counter doesn't have to increment on every cycle, you just have to know how many cycles are taken by each tick. You can then multiply countedTicks by cyclesPerTick to get the number of cycles.
To get a run-time value you could temporarily disable process interrupts and count the number of ticks that occur in 1 second to get totalExpectedTicks, then divide it into the processor clock frequency to get cyclesPerTick (or, since the answer you want is only a ratio, you could just work in ticks and not worry about how many cycles they represent).