Display CPU Utilization with Hyperthreading CPU

  • Thread starter Thread starter jim_adams
  • Start date Start date
J

jim_adams

Using the System.Management.ManagementObject and "Select * From
Win32_PerfRawData_PerfProc_Process" syntax enables my app to return CPU
utilization for a specific application.

However, on an Intel CPU with Hyperthreading, CPU Utilization is twice
the value shown by the Task Manager. A multiplier error may also be
introduced with Dual Core CPUs, but I don't have access to one to test
it out.

Is there a way to get an accurate CPU Utilization value (e.g. as
displayed by Task Manager) for a process regardless of the CPU type?

Thanks,

Jim
 
Using the System.Management.ManagementObject and "Select * From
Win32_PerfRawData_PerfProc_Process" syntax enables my app to return
CPU utilization for a specific application.

However, on an Intel CPU with Hyperthreading, CPU Utilization is twice
the value shown by the Task Manager. A multiplier error may also be
introduced with Dual Core CPUs, but I don't have access to one to test
it out.

Is there a way to get an accurate CPU Utilization value (e.g. as
displayed by Task Manager) for a process regardless of the CPU type?

These values are based on the performance counters in system categories
Processor and Process, which you can access through the PerformanceCounter
class. The Processor values will supply CPU usage for each processor
independently, but only over all processes. The Process category supplies
counters for each process, but they are only averages over all CPUs; you
can't extract independent usages for each CPU per process. I don't know any
way around this other than to run the application while nothing else is
running and use the Processor counters. You may be able to compensate
somewhat for error by simultaneously examining the CPU usage of all other
processes, but you don't really know how much of each CPU they're all using.
I hope this helps.
 
Back
Top