Click here to Skip to main content
15,861,168 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I'm trying to understand why different tools show different results for CPU utilization.

I created a simple loop that should completely consume all CPU resources. However, depending which tool I use for observation of the CPU load I see very different results.

The situation is roughly like this:

  • Task manager shows maximum of 45% CPU load, the load is almost constant.
  • Visual Studio Diagnostic tool shows load between 50% and 100% and the average is roughly 75%
  • Windows performance monitor shows 100% load all the time when the test is running.

Note that these observations are from the same test run at the same time, just using different tools. What could cause such different results?

My computer contains 4 cores so anything less than 4 threads shows smaller utilization but with 4 or more threads the result is as described. The OS is Windows 10 Pro.

What I have tried:

The test I used
C#
public static void Oper() {
   int a = 1;
   while (1 == 1) {
      a += 1;
      a -= 1;
   }
}

static void Main(string[] args) {
   System.Threading.Thread t1 = new System.Threading.Thread(Oper);
   System.Threading.Thread t2 = new System.Threading.Thread(Oper);
   System.Threading.Thread t3 = new System.Threading.Thread(Oper);
   System.Threading.Thread t4 = new System.Threading.Thread(Oper);
   System.Threading.Thread t5 = new System.Threading.Thread(Oper);
   System.Threading.Thread t6 = new System.Threading.Thread(Oper);
   System.Threading.Thread t7 = new System.Threading.Thread(Oper);

   t1.Start();
   t2.Start();
   t3.Start();
   t4.Start();
   t5.Start();
   t6.Start();
   t7.Start();
   Oper();
}
Posted
Updated 21-Aug-17 6:11am
v3
Comments
Wendelius 21-Aug-17 12:34pm    
Thank you, that's an interesting thread to read, especially the answer from @Stefan63

While all the conversation makes sense I still don't understand why I'm seeing so different results at the same time... Seems like the tools are observing the situation very differently. What puzzles me most is the difference between Performance Monitor and Task Manager
[no name] 21-Aug-17 12:58pm    
Keep in mind the conclusion of stefan63 was/is "wrong". Need some time to recover the case. Maybe I can come back with some helpfull Information, maybe...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900