System.Diagnostics.PerformanceCounterType Enumeration

Specifies the formula used to calculate the PerformanceCounter.NextValue method for a System.Diagnostics.PerformanceCounter instance.

[System.ComponentModel.TypeConverter(typeof(System.Diagnostics.AlphabeticalEnumConverter))]

public enum**PerformanceCounterType**

public enum

Some counter types represent raw data, while others represent calculated values that are based on one or more counter samples. The following categories classify the types of counters available.

Average: measure a value over time and display the average of the last two measurements. Associated with each average counter is a base counter that tracks the number of samples involved.

Difference: subtract the last measurement from the previous one and display the difference, if it is positive; if negative, they display a zero.

Instantaneous: display the most recent measurement.

Percentage: display calculated values as a percentage.

Rate: sample an increasing count of events over time and divide the change in count values by the change in time to display a rate of activity.

When sampling performance counter data, using a counter type that represents an average can make raw data values meaningful for your use. For example, the raw data counter NumberOfItems64 can expose data that is fairly random from sample to sample. The formula for an average calculation of the values that the counter returns would be (X _{} +X _{} +…+X _{})/n, where each X _{} is a raw counter sample.

Rate counters are similar to average counters, but more useful for situations in which the rate increases as a resource is used. A formula that quickly calculates the average is ((X _{} -X _{})/(T _{} -T _{})) / frequency, where each X _{} is a counter sample and each T _{} is the time that the corresponding sample was taken. The result is the average usage per second.

Unless otherwise indicated, the time base is seconds.

When instrumenting applications (creating and writing custom performance counters), you might be working with performance counter types that rely on an accompanying base counter that is used in the calculations. The base counter must be immediately after its associated counter in the System.Diagnostics.CounterCreationDataCollection collection your application uses. The following table lists the base counter types with their corresponding performance counter types.

AverageBase |
AverageTimer32 AverageCount64 |

CounterMultiBase |
CounterMultiTimer CounterMultiTimerInverse CounterMultiTimer100Ns CounterMultiTimer100NsInverse |

RawBase |
RawFraction |

SampleBase |
SampleFraction |