How to Measure Separate CPU Core Usage for a Process

How to get accurate CPU usage for a process on a multi-processor / multi-core system

You are rigt - you have to divide the number from Performance Counters by the number of CPUs times the number of real threads per CPU - one per core, plus one per core if hyperthreading is a factor.

In C# I don't know how to determine this. In native code you can use GetLogicalProcessorInformation and its associated structure to count the logical processors, including those that share a core.

(Batch) wmic cpu issue with multi-core system

It is probably funny that I give an answer to MY question, but since I searched and tested a lot, I want to share one more option:

I used the "typeperf" and I found the result really close to the task manager CPU utilization.

The command for the console is:

typeperf "\Processor Information(_Total)\% Processor Utility"

or the one below for a batch file:

typeperf "\Processor Information(_Total)\%% Processor Utility"

The bad points are:

1) The output format is not very handy (e.g. "01/29/2019 21:24:26.000","8.650791" )

2) If the CPU utilization is 100%, the output is >100 (Basically ~120)

3) If the CPU utilization is 1-2%, the output is ~0.5 (Basically <1.5)



Related Topics



Leave a reply



Submit