This documentation is archived and is not being maintained.

Runtime Profiling

Profiling is a method of gathering performance data in any development or deployment scenario. This section is for developers and system administrators who want to gather information about application performance.

The Performance Monitor (or, in Windows Vista, the Reliability and Performance Monitor) is the easiest tool to use to profile your .NET Framework application. The Performance Monitor graphically represents data found in the .NET performance counters that are installed with the common language runtime and the Windows Software Development Kit (SDK). These counters can be used to monitor everything from memory management to just-in-time (JIT) compiler performance. They tell you about the resources your application uses, which is an indirect measure of your application's performance. Use these counters to understand how your application works internally rather than to directly measure your application's performance.

To run Perfmon.exe

  1. At the command prompt, type perfmon. The Performance console appears.

  2. In the toolbar, click the Add icon (the plus sign), if it is present. If it is not present, right-click in the monitor window and select the Add Counters option. This opens the Add Counters dialog box.

  3. Select the performance counter you want to view. There are a number of predefined counters for .NET applications, including those for memory management (.NET CLR Memory), interoperability (.NET CLR Interop), exception handling (.NET CLR Exceptions), and multithreading (.NET CLR LocksAndThreads).


When new performance counters are installed while the NT Performance console is running, stop and restart the Performance console to make the new counters visible.

If you want to profile an assembly that exists in a zone or on a remote share, make sure that the remote assembly has full trust on the computer that runs the performance counters. If the assembly does not have sufficient trust, the performance counters will not work. For information about granting trust to different zones, see the Code Access Security Policy Tool (Caspol.exe).

The .NET Framework provides classes you can use to programmatically access the same performance information that is available in the Performance console. You can also use these classes to create custom performance counters. The following table describes some of the performance monitoring classes that are provided in the .NET Framework.




Represents a Windows NT performance counter component. Use this class to read existing predefined or custom counters and publish (write) performance data to custom counters.


Provides several methods for interacting with counters and categories of counters on the computer.


Specifies an installer for the PerformanceCounter component.


Specifies the formula to calculate the NextValue method for a PerformanceCounter.