|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
CounterSample & nextSampleaverage utilization over a 5 minute period). I found the below article that seems to do a reasonably complete job of explaining the differences between raw, calculated and sampled performance data. http://msdn2.microsoft.com/en-us/library/xb29hack.aspx CPU utilization is of type Timer100NsInverse. So here is my question: to get the most accurate 5 minute average of CPU utilization, should I be taking a sample at 0 minutes, another sample at 5 minutes, and then calculate the results (see below code for an example)? Advice would be appreciated. Thanks in advance. Joe // 1st sample counter = new PerformanceCounter("Processor", "% Processor Time", "_Total", "192.168.130.9"); sample1 = counter.NextSample(); counter.Close(); Thread.Sleep(5*60*1000); // 2nd sample counter = new PerformanceCounter("Processor", "% Processor Time", "_Total", "192.168.130.9"); sample2 = counter.NextSample(); counter.Close(); // Output results Console.WriteLine("CPU util = " + CounterSample.Calculate(sample1, sample2)); |
|||||||||||||||||||||||