Export (0) Print
Expand All

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 and Windows 7, 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 Framework 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.

To run Perfmon.exe on Windows XP

  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, which displays the available performance objects and counters. There are a number of predefined objects for .NET Framework applications, including those for memory management (.NET CLR Memory), interoperability (.NET CLR Interop), exception handling (.NET CLR Exceptions), and multithreading (.NET CLR LocksAndThreads). Each .NET Framework performance object includes a number of individual performance counters.

  3. In the Performance object list, click the performance object you want to view.

  4. In the counters list, click the performance counter you want to view.

  5. Click All Instances to specify that you want to monitor the performance counter for the common language runtime globally (that is, on a system-wide basis).

    -or-

    Click Select instances from list and click an application to monitor the performance counter for that application.

    To differentiate multiple versions of the runtime, or to disambiguate multiple applications with the same name, you must also modify a registry key. For more information, see Performance Counters and In-Process Side-By-Side Applications.

To run Perfmon.exe on Windows Vista and Windows 7

  1. At the command prompt, type perfmon. The Reliability and Performance Monitor console (in Windows Vista) or the Performance Monitor console (in Windows7) appears.

  2. In the Monitoring Tools folder, click Performance Monitor.

  3. In the Performance Monitor 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. The Available counters list box displays the available performance objects. There are a number of predefined objects for .NET Framework applications, including those for memory management (.NET CLR Memory), interoperability (.NET CLR Interop), exception handling (.NET CLR Exceptions), and multithreading (.NET CLR LocksAndThreads). Each performance object includes a number of individual performance counters.

  4. Select the check box next to a performance object's name to view the list of individual performance counters that it supports.

  5. Click the performance counter you want to view.

  6. In the Instances of selected object list box, click <All instances> to specify that you want to monitor the performance counter for the common language runtime globally (that is, on a system-wide basis).

    -or-

    In the Instances of selected object list box, click an application name to monitor the performance counter for that application.

    To differentiate multiple versions of the runtime, or to disambiguate multiple applications with the same name, you must also modify a registry key. For more information, see Performance Counters and In-Process Side-By-Side Applications.

Note Note

When new performance counters are installed while the 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 Caspol.exe (Code Access Security Policy Tool).

Note Note

   On systems on which the .NET Framework 4 is installed, the Performance Monitor may not display data for performance counters in some categories, such as .NET CLR Data and .NET CLR Networking, for applications that were developed using the .NET Framework 1.1. If this is the case, you can configure Performance Monitor to display this data by adding the <forcePerformanceCounterUniqueSharedMemoryReads> element to the application's configuration file.

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.

Class

Description

System.Diagnostics.PerformanceCounter

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.

System.Diagnostics.PerformanceCounterCategory

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

System.Diagnostics.PerformanceCounterInstaller

Specifies an installer for the PerformanceCounter component.

System.Diagnostics.PerformanceCounterType

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

Show:
© 2014 Microsoft