CPU usage does not match Task Manager, PerformanceCounter or ManagementObjectSearcher

时间:2016-02-12 21:37:01

标签: c# cpu-usage performancecounter

I am just trying to get accurate CPU usage that matches Task Manager. So far I have tried four recommended methods that do not work.

First, I have tried the similar solutions or suggestions given that I could find. The code sample here uses four methods, all of which are inaccurate. Second, I know that Task Manager fluctuates and depends on when it is sampled. That still does not account for the differences. Lastly, I know there are different methods, and that Task Manager uses just one method. Since this is intended for general users, it needs to be close to Task Manager.

destinationViewController

Here are two samples comparing to task manager. enter image description here enter image description here

From the picture you can see I have a dual core CPU, with four logical processors. The CPU is a Intel Skylake i7-6650U, running Windows 10.

Thanks

For reference - These links are similar: PerformanceCounter reporting higher CPU usage than what's observed How to get the CPU Usage in C#? Calculate CPU usage for a Windows process?

1 个答案:

答案 0 :(得分:1)

你有2个核心,但有4个线程,所以你需要除以4,而不是2.我怀疑你的WMI方法只会检查1个核心。检查是否有多个win32_processor对象可用。