0

I'm trying to retrieve the performance information of all physical cores on my machine. I have attempted the following code:

ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_PerfFormattedData_PerfOS_Processor");
    foreach (ManagementObject obj in searcher.Get())
    {
        var usage = obj["PercentProcessorTime"];
        var name = obj["Name"];
    }

Sourced from here

However, this returns the info of the logical processors and not the physical cores. For example, I have a hyperthreaded quad-core and therefore this code returns the info for 8 processors where, in fact, I only want the 4 physical one

Community
  • 1
  • 1
wmash
  • 4,032
  • 3
  • 31
  • 69
  • That's because the physical cores don't have a number to expose. What number do you expect it to return, the average between the two logical cores? And if so, why not just do the average yourself? – Scott Chamberlain Jun 02 '16 at 21:43
  • For example, OpenHardwareMonitor retrieves only the physical cores and represents the load, speed and temp of each one – wmash Jun 02 '16 at 21:45
  • 1
    I am not sure how they are calulating Load, but speed and temp are going to be shared by the two logical cores so it makes sense. But the info exposed by `Win32_PerfFormattedData_PerfOS_Processor` is logical specific. – Scott Chamberlain Jun 02 '16 at 21:49
  • Okay, thank you very much! I think I'll attempt to work out the average and see if it matches up – wmash Jun 02 '16 at 21:50
  • @wmash if you end up solving this on your own, please post an answer here for the benefit of whoever else reads your question in the future. – ashes999 Jun 03 '16 at 15:47

0 Answers0