using System;
using System.Diagnostics;

class Program
{
   
static void Main(string[] args)
    {
        PerformanceCounter[] counters
= new PerformanceCounter[ System.Environment.ProcessorCount ];
       
for(int i=0; i<counters.Length; i++)
        {
            counters[i]
= new PerformanceCounter("Processor", "% Processor Time", i.ToString());
        }

       
while(true)
        {
           
for(int i=0; i<counters.Length; i++)
            {
               
float f = counters[i].NextValue();
                Console.WriteLine(
"CPU-{0}: {1:f}%", i, f);
            }
            Console.WriteLine();
            System.Threading.Thread.Sleep(
1000);
        }
    }
}
posted on 2009-05-13 14:51  Sail  阅读(507)  评论(0编辑  收藏  举报

最新资讯 最新游戏 最新网页游戏