PerformanceHelper for easy PerformanceCounter integration

In the Speedy Rewards team here we use custom PerformanceCounters quite extensively to monitor and trend our host systems.  You may not know, but our rewards program implements real-time host integration for transactions that are Id’ed as a SpeedyRewards member such that systems like the in-store kiosk,, and any other store you may soon visit can accurately reflect balance updates immediately.  With 1600+ stores doing this and a sub-1 second response time, we need to keep a close eye on things.

Today I was trying to do some preliminary performance profiling on our new WCF based messaging infrastructure.  To make my life a little easier, I put together a PerformanceHelper class that I actually modeling off the Tracer class found in the Enterprise Library 1.1.  To use it, you wrap a section of code you wish to monitor performance for with the following:

using(new PerformanceHelper(CATEGORY, "<BlockInstanceName>") )

This will provide you with a RateOfCountsPerSecond32 counter and an AverageTimer32 counter called “Operations/sec\<BlockInstanceName>” and “Average Time/Operation\<BlockInstanceName>” respectively.  You can download the PerformanceHelper class here and a sample project here

Feel free to use and abuse it, but be aware that this has not fully tested and may well contain bugs.  I provide NO warranty or guarantees, so don’t come to me when your server blue-screens from a corrupt registry (not that I’ve ever done that).  Use at your own peril.

Leave a Reply

Your email address will not be published. Required fields are marked *