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
Get Started with Latex on Linux
Symbolic Link to a Hook in Git
How to Install Crontab on Centos
Is Usb Supported on Bash on Ubuntu on Windows 10
Building Linux Kernel on MAC Os X
Id_Rsa.Pub File Ssh Error: Invalid Format
How to Add a Custom Footer to Sphinx Documentation? (Restructuredtext)
How to Convert Pe(Portable Executable) Format to Elf in Linux
Linux Makefile Structure and Documentation
How to Parse /Proc/Pid/Cmdline
How to Write Multiple Line String Using Bash with Variables
How to Edit a Binary File on Unix Systems
JSON Command Line Formatter Tool for Linux
Shell Init Issue When Click Tab, What's Wrong with Getcwd
How to Add My Own Software to a Buildroot Linux Package
Check If Environment Variable Is Already Set