
Implementing an AverageTimer32 Performance Counter in .NET
Use just one performance counter to monitor performance, not with new AverageTimer32 Performance Counters
A task that I’m working on involves injecting quite a chunk of processing in to a performance sensitive part of the system. Luckily the system already uses performance counters to monitor the performance of this part of the system. Unfortunately it turns out that performance counters are hard. This is similar to the code that was originally in the measurement code:
I kind of understand what the code is attempting to do, but not really. The documentation for QueryPerformanceFrequency kind-of helps, mostly by pointing to a different document. Reading this documentation it becomes obvious that there is a simpler way of obtaining the value that is needed:
The Stopwatch class really is very useful, and hides a lot of the complexity around getting accurate time measurements. And that’s why we’re writing .NET code and not C or C++, right?