Skip to main content
Visual C++ Samples 
PerformanceCounter Sample: Performance Monitoring in an ATL Server Application 

Download sample

Demonstrates how to expose performance information using ATL Server's performance monitoring support within a Web application.

The PerformanceCounter sample presents a Web page with three buttons, each of which is represented by an instance of a performance object. When one of the buttons is clicked, the sample updates the corresponding performance object's counter values.

The results can be viewed using the Windows Performance Console.

This sample demonstrates:

  • Defining performance objects and counters within an ATL Server application.

  • Using the nonattributed variety of the ATL performance monitoring API.

  • Creating multiple instances of a performance object.

  • Accessing performance objects from an ATL Server request handler.

  • The ATL Server classes CPerfMon and CPerfObject.

Security noteSecurity Note

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.


  • IIS

Building and Running the Sample

To build and run this sample

  1. Open the solution file, PerformanceCounter.sln, in the Visual Studio development environment.

  2. Build the solution. This will also deploy the solution to the local Web server.

  3. Use a Web browser to view http://localhost/performancecounter/performancecounter.srf.

  4. Run the Windows Performance Monitor. (Click the Start button, click Run, type perfmon in the Open box, and click OK.)

  5. Within the Performance Console, click the Add button on the toolbar (represented by a plus sign) to open the Add Counters dialog box.

  6. In the Performance objects box, select PerformanceCounterSample.

  7. Select the All instances and All counters radio buttons and click Add.

  8. Position the Performance Console and Web browser windows so that they do not overlap.

  9. Click the buttons on the PerformanceCounter Web page and watch as the Performance Monitor charts the counter values.


See Also