PerformanceCounter cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total"); float cpuUsage = cpuCounter.NextValue();
PerformanceCounter memCounter = new PerformanceCounter("Memory", "Available MBytes"); float memUsage = memCounter.NextValue();
PerformanceCounter netCounter = new PerformanceCounter("Network Interface", "Bytes Total/sec", "eth0"); float netUsage = netCounter.NextValue();The System.Diagnostics namespace in C# contains various classes for interacting with the performance counters on Windows systems, including PerformanceCounter, PerformanceCounterCategory, and PerformanceCounterInstaller. Therefore, System.Diagnostics is the package library that contains the PerformanceCounter class.