Display CPU Utilization with Hyperthreading CPU

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
 
D

Derrick Coetzee [MSFT]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top