|
|
How Do I...Count rate of change?Windows performance counters enable your applications and components to publish, capture, and analyze the performance data that applications, services, and drivers provide. You can use this information to determine system bottlenecks and fine-tune system and application performance. For example, you can use a performance counter to track the number of orders processes per second or the number of users currently connected to the system. Using the common language runtime's PerformanceCounter component, you can easily create your own custom counters and publish performance data relevant to your application, such as those mentioned above.This sample illustrates how to publish the number of orders processed per second using a custom performance counter. It's a small console application you can run from the command prompt. > PCDemo.exe Now, wait for the application to display "Started" and run the PerfMon.exe. In PerfMon, choose the Add toolbar button. A dialog will open. Select the ACounterDemo performance object, CountPerSecond counter, and _Total instance. Choose Add, close the dialog, and notice that you can use the PCDemo sample to change the published value by pressing + or -. When the application starts, it simulates the processing of two new orders per second. The + and - keys can be used to double the number or divide it in two. In its simplest form, writing to a custom performance counter that counts number of items per second involves:
Example
|