如何以编程方式检查网站cpu使用情况?
答
How to calculate the CPU Usage Programmatically using C# or VB.NET使用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();
}
答
读取CPU性能计数器是一种方法。
编程,或者这是否属于超级用户或serverfault? – shoover 2009-12-16 23:33:34
只要你是以编程方式表示,它就属于这里。 – 2009-12-17 01:53:57