Skip to main content
Visual C++ Samples 
PerformanceScribble Sample: Performance Monitoring in an MFC Application 

Download sample

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

The PerformanceScribble sample is identical to the MFC Scribble sample, except that performance data support has been added.

This sample demonstrates:

  • Defining performance objects and counters within an MFC application.

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

  • Performance monitoring support used outside of an ATL Server application.

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

Building and Running the Sample

To build and run this sample

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

  2. From the Build menu, click Build Solution.

  3. From the Debug menu, click Start Without Debugging. The PerformanceScribble application will open displaying a window where you can draw with the mouse.

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

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

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

  9. Move the mouse around within the drawing area of the PerformanceScribble application and observe the changes in the Performance Console.

How the Sample Works

ATL Server's performance monitoring support must reside within a DLL, so this sample uses two subprojects: one to generate a performance-enabled DLL, and the other to generate an EXE. Together they form the PerformanceScribble sample and expose three counters:

  • Horizontal mouse movement

  • Vertical mouse movement

  • Mouse events per second

Note that without a performance monitoring application such as the Windows Performance Console to monitor performance output, the PerformanceScribble demonstration looks exactly like the MFC Scribble sample. There is no external evidence that performance-monitoring support has been added.


See Also