I want to measure the cpu usage of each processor.
When I run the following program, I get instance name 2
, 3
, 0
, 1
, and _Total
. I thought I should get 0
, 1
, 0,_Total
, 1,_Total
.
What does the result mean? How to get the total cpu usage of each processor. Not each core?
class PerfMonitor
{
static void Main()
{
var pc = new PerformanceCounter("Processor", "% Processor Time");
var cat = new PerformanceCounterCategory("Processor");
var instances = cat.GetInstanceNames();
foreach (var s in instances)
{
pc.InstanceName = s;
Console.WriteLine("instance name is {0}", s);
}
}
}