Profiling is a method of gathering performance data in any development or deployment scenario. This section is of interest to developers and system administrators who want to gather information about application performance.
Tracking Performance Using the Performance Console (Perfmon.exe)
The Windows 2000 and Windows NT Performance console is the easiest tool to use to profile your .NET Framework application. The System Monitor graphically represents data found in the .NET performance counters that are installed with the common language runtime and the Microsoft .NET Framework 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
- At the command prompt, type perfmon. The Performance console appears.
- In the toolbar, click the Add icon (the plus sign) and select the performance counter you want to view.
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).
Reading and Creating Performance Counters Programmatically
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.
|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.|