views:

329

answers:

2

Years ago I wrote some code to "publish" data for perfmon to consume. Using those counters is pretty well documented, but I found it challenging to find (at the time) good documentation and sample code to publish the data for perfmon.

Does anyone know where I can get this documentation? I also seem to recall some class wrappers, but I may be mistaken.


EDIT:

I did find this, and I will keep looking for "custom application performance counters".

+1  A: 

Are you looking for Managed or native wrappers? The link you posted is managed, but your question is native (c++). In managed world things are fairly easy and straight forward to publish counters using the PerformanceCounter and it relatives http://msdn.microsoft.com/en-us/library/system.diagnostics.performancecounter.aspx. For moderate volumes they can also be used for reading counters, for high volumes though you must use the PDH.DLL as the overhead of the managed counters reading one counter at a time will be overwhelming in my experience. Personally I developed XSLT transformations to generate all prfmon counters in my apps, I blogged about this here: http://rusanu.com/2009/04/11/using-xslt-to-generate-performance-counters-code/ and I have more upcoming material to blog down the pipe. If your question is about the unmanaged API, I don't have any pointer handy, but me personally I would go down the path of using again XSLT to generate all my perfmon code, as so much of it is repetitive.

Remus Rusanu
you're right - I want native, though I may go managed if it is that simple.
Tim
+1  A: 

You're bringing back old memories!

From 1998, Jeffrey Richter wrote an article in Microsoft Systems Journal describing how to create your own perfmon counters, its very easy (after cutting and pasting his template code just add shared-memory variables in a dll, and update them as needed).

gbjbaanb
that's exactly the one I had to reference years ago. Thanks
Tim