PerformanceCounter reports higher CPU utilization than what is observed

I am currently doing this:

PerformanceCounter cpuUsage = new PerformanceCounter("Processor", "% Processor Time", "_Total");
cpuUsage.NextValue();
System.Threading.Thread.Sleep(1000);
RV = cpuUsage.NextValue();

I periodically call a function to get CPU usage. When I track the system in TaskManager, the CPU utilization indicated by PerformanceCounter is constantly 15-20% higher than TaskManager reports (30% in TaskManager = 50% of PerformanceCounter).

Maybe there is documentation that I forgot, but does anyone have an explanation? Perhaps the CPU usage at the time of its verification is higher, and the task manager reports an average?

+3
source share
1 answer
  new PerformanceCounter("Processor", ...);

, Perfmon. " " "". , , . "" - , :)

+5

Source: https://habr.com/ru/post/1628576/


All Articles