Walkthrough: Command-Line Profiling Using Sampling
This walkthrough demonstrates how to profile an application by using command-line tools and sampling to identify performance problems.
In this walkthrough, you will step through the process of profiling a managed application by using command-line tools, and use sampling to isolate and identify performance problems in the application.
In this walkthrough, you will follow these steps:
Profile an application by using command line tools and sampling.
Analyze sampled profiling results to locate and fix performance issues.
Prerequisites
Microsoft Visual Studio 2005 Team System
Intermediate understanding of C#
Intermediate understanding of working with command line tools
A copy of the PeopleTrax Sample (Profiling Tools)
To work with the information provided by profiling, it is best to have debugging symbol information available.
Command Line Profiling Using the Sampling Method
Sampling is a profiling method by which a specific process is periodically polled to determine the active function. The resulting data provides a count of how frequently the function was on top of the call stack when the process was sampled.
To profile an existing application by using the sampling method
Open a command prompt window. If necessary, add the profiler tools directory to your PATH environment variable. The path is not added at installation.
32 bit computers
On 32 bit computers, the default profiler tools directory is
\Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools.
64 bit computers
On 64 bit computers, specify the path according to the target platform of the application to be profiled.
To profile 32 bit applications, the default profiler tools directory is
\Program Files (x86)\Microsoft Visual Studio 9.0\Team Tools\Performance Tools
To profile 64 bit applications, the default profiler tools directory is
\Program Files (x86)\Microsoft Visual Studio 9.0\Team Tools\Performance Tools\x64
For example, to add the profiler directory to PATH on a 32 bit computer, type
set path=%path%;C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools
Note
If you are profiling a managed application, go to the next step. If not, go to step 3.
Type the following command to set the appropriate environment variables:
VSPerfCLREnv /sampleon
Start profiling by running VSPerfCmd.exe, which is the command-line tool that controls the profiler. The following command starts the application and profiler in the sampling mode:
VsPerfCmd /start:sample /output: \\<dir>\PeopleTraxReport.vsp /launch:\\<dir>\PeopleTrax.exe
The profiler process starts and attaches to the PeopleTrax.exe process. The profiler process starts to write the collected profiling data to the report file.
Click Get People.
Click ExportData.
Notepad opens and displays a new file that contains the exported data from PeopleTrax.
Close Notepad, and then close the PeopleTrax application.
Shut down the profiler. Type the following command:
VSPerfCmd /shutdown
For profiling managed applications, use the following command to reset the environmental variables:
VSPerfCLREnv /sampleoff
Analyze the results by using one of the following methods:
Examine the raw .vsp file in the Visual Studio IDE.
— or —
Generate a more detailed report by using the command-line tool VSPerfReport.exe. To generate reports for use outside the Visual Studio IDE use the following command:
VSPerfReport <dir> PeopleTraxReport.vsp /output:<dir> /summary:all
See Also
Concepts
Profiling Tools Performance Session Overview
Understanding Sampling Data Values in Profiling Tools