1. What are Performance Counters

I strongly recommend you read two in-depth posts about Peformance Counter:

2. List Performance Counters

How to list all of the performance counters available on your computer? Run the following command in the command console:

> TypePerf.exe –q

3. Restore Performance Counters

If some counters are missing from your computer, how to rebuild them? Run the command console as Administrator:

> cd C:\WINDOWS\system32
> lodctr.exe /R
> lodctr.exe /R
> cd C:\Windows\SysWOW64
> lodctr.exe /R

If you meet errors while running “lodcrt.exe”, the best try is to run it once again.

4. Common Performance Counters

In the table below, I’ve listed some of the usally used counters and the properties to create them in c#:

Benchmark categoryName counterName instanceName
Processor % Usage "Processor" "% Processor Time" "_Total"
Memory Available Bytes "Memory" "Available Bytes" ""
Disk % Idle Time "PhysicalDisk" "% Idle Time" "_Total"
Disk Read Bytes/sec "PhysicalDisk" "Disk Read Bytes/sec" "_Total"
Disk Write Bytes/sec "PhysicalDisk" "Disk Write Bytes/sec" "_Total"
Network Bytes Received/sec "Network Interface" "Bytes Received/sec" NID
Network Bytes Sent/sec "Network Interface" "Bytes Sent/sec" NID
Network Throughput "Network Interface" "Bytes Total/sec" NID

NID refers to the name of the network card. To print out the network cards on your computer:

public void printNetworkCards()
{
    PerformanceCounterCategory category = new PerformanceCounterCategory("Network Interface");
    string[] names = category.GetInstanceNames();

    foreach (string name in names)
    {
        Console.WriteLine(name);
    }
}