There are several ways you can read performance counter values:
The interaction between raw values, next (or calculated) values, and samples is fairly straightforward once you understand that raw and calculated values shift constantly, whereas samples allow you to retrieve a static snapshot of the counter at a particular point in time. The following diagram illustrates the relationship between raw value, next value, and samples.
Performance Counter Values: Raw, Calculated, and Sampled
This picture shows a representation of the data contained in a counter called Orders Per Second. The raw values for this counter are individual data points that vary by second, where the calculated average is represented by the line showing an increasing order receipt over time. In this chart, the following data points have been taken:
Retrieving a raw value with the RawValue property is very quick, because no calculations or comparisons are performed. For example, if you are using a counter simply to count the number of orders processed in a system, you can retrieve the counter’s raw value. For instructions on retrieving raw values, see Retrieving Raw Values from Performance Counters.
Retrieving a calculated value with the NextValue method is often more useful than retrieving the raw value, but this value may also give you an unrealistic view of the data because it can reflect unusual fluctuations in the data at the moment when the value is calculated. For example, if you have a counter that calculates the orders processed per second, an unusually high or low amount of orders processed at one particular moment will result in an average that is not realistic over time. This may provide a distorted view of the actual performance of your system. For instructions on retrieving a calculated value, see Retrieving Calculated Performance Counter Values.
Samples provide the most realistic views of the data in your system by allowing you to retrieve, retain, and compare various values over time. You would retrieve a sample, using the NextSample method, if you needed to compare values in different counters or calculate a value based on raw data. For instructions on retrieving a sample, see Retrieving a Sample of Performance Counter Values.
The NextSample method returns an object of type CounterSample. When you retrieve a sample, you have access to properties on the CounterSample class such as RawValue, BaseValue, TimeStamp, and SystemFrequency. These properties let you get a very detailed look at the data that makes up the sample data.
Retrieving Raw Performance Counter Values | Retrieving Calculated Performance Counter Values | Retrieving a Sample of Performance Counter Values | Introduction to Monitoring Performance Thresholds