views:

134

answers:

1

I have an application that is executing a number of operations. I have some performance counters that measure the average time it takes to execute the operation between intervals. I would like a counter that for each interval will display the maximum time that it took to handle one of the operations since the last interval.

For an average I use a PerformanceCounter of type AverageTimer32 instance and an AverageBase instance. What kind of performance counter would I use for tracking the maximum operation time between intervals? How would it be incremented?

+1  A: 

There is no such counter type. Trying to implement your own (read current value, compare, change if is a new max) is flawed under concurency conditions as there is no atomic interlockedcompareexchange API for performance counter.

Remus Rusanu
Does that mean implementing something like this is not possible?
spoon16
You can use an variable that tracks the max value and is incremented under appropiate locking, and publish it as an ordinary absolute counter.
Remus Rusanu
It doesn't seem like that is really an option. You can't tell when the last interval is taken so you can't keep track of the max since the last interval.
spoon16
You keep track of max since the application start up time. Or you keep a series in the application and manage it your self and publish a counter as 'max in the last 60 seconds' for example. A max between the intervals *for each reader* is impossible, it means the perf counters need to keep track of readers, which is not how counters work, all they have is *one* single raw value, the rest is computed by the readers
Remus Rusanu