I’m trying to use c#’s performance counters to track the throughput of an application (a windows service actually). But I have a question on how to tackle this… My application parses XML documents and I want to monitor how many documents are parsed per unit of time.
I’m using _counter.Increment() every time I parse a document, but this always gives me the total number of documents parsed (a flat graph). I would like to make nice plots where I could set the interval to be sampled, and get the count within that interval.
Is this possible using performance counters or should I take a different approach?
Thanks.
If you want to see a rate of items (per second, for example) you need to use a different counter type. For example:
PerformanceCounterType.RateOfCountsPerSecond32
If you increment this for each item, it will show up in Performance as a count per second instead of a total count (which is what you get with PerformanceCounterType.NumberOfItems32).