Calculating Averages with Performance Counters

前端 未结 1 1402
广开言路
广开言路 2021-02-07 09:39

I have a service process, and I want to use performance counters to publish the average time that it takes to complete tasks. I am using the AverageTimer32 counter to do this.<

相关标签:
1条回答
  • 2021-02-07 10:20

    It turns out that the reason that I could not do what I wanted was that none of the performance counter types provide for automatically calculating a running average. (the "average" counters, calculate an average based upon that moment in time, like "bytes per second").

    I wanted a running average. So, I used the RawFraction performance counter type.

    There was one problem with that method: The formula divides the result by 100 to produce a percentage, and I wanted a raw number (average operations completed per second).

    So, I incremented the denominator of the fraction by 100 for every 1 operation (offsetting the percentage calculation).

    My result: I can now display how long it takes, on average, for my service to complete a task. If my service isn't busy, the average remains constant so that you can see the long-term trend of my service's performance.

    0 讨论(0)
提交回复
热议问题