Windows – How is CPU usage computed

cpu-usagewindows

The Windows Task Manager shows CPU usage in percentage. What's the formula behind this? Is it this:

% CPU usage for process A = (Sum of
all time slices given to A till now)/
Total time since the machine booted

Or is it something else?

Best Answer

I am not 100% sure what is uses, but I think you are a bit off on the CPU calculation.

I believe they are doing something like.

Process A CPU Usage = (Cycles for A over last X seconds)/(Total cycles for last X seconds)

I believe it is tied to the "update interval" set in task manager.

While doing a bit of research for you though I found this MSDN article that shows a microsoft recommended way of calculating the CPU time of a set of instructions, this might point you a bit towards their calculation as well.