views:

195

answers:

3

Hello, 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.

A: 

You could always decrement the counter when you finish parsing a file. This way, you get the number of active parses at any one point in time, which will realistically give you a none-linear graph because these parses will take different intervals.

Pete OHanlon
A: 

hi,

easiest is to store the timestamps of when a document is finished (so one big array)

given this data, you can easily deduct the total done, the speed of processing, the speed change per time step etc etc.

Doing these statistics can be done with excel (just to start with), and later with some fancy graphs library you can add to your software

Toad
+2  A: 

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).

Chris Patterson