tags:

views:

357

answers:

2

Does anyone know how to check the CPU usage of a website in IIS or by any other means? Thanks very much.

A: 

Reading the CPU performance counter is one way.

RickNZ
+3  A: 

How to calculate the CPU Usage Programmatically using C# or VB.NET using PerformanceCounter.

static PerformanceCounter cpuUsage;
public static void Main(string[] args)
{
    cpuUsage = new PerformanceCounter("Processor", "% Processor Time", "_Total");

    Console.WriteLine(cpuUsage.NextValue() + " %");
    Thread.Sleep(1000);
    Console.WriteLine(cpuUsage.NextValue() + " %");
    Console.Read();
}
David Glass