|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
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.
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 window and locate the directory that contains the sampling command-line tools.
For profiling a managed application, type the following command to set the appropriate environment variables:VsPefCLREnv /sampleon
Start profiling by running VSPerfCmd.exe, which is the command-line tool that controls the profiler. The following command starts the profiling session 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 Export Data.
Notepad opens and displays a new file that contains the exported data from PeopleTrax.
Close Notepad, and then close the PeopleTrax application.
For profiling managed applications, use the following command to reset the environmental variables:VSPerfCLREnv /off
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
For additional walkthroughs related to reporting profiling data from the command line, see:
How to: Gather Sampling Data using Command-line Tools
How to: Gather Instrumentation Data using Command-line Tools
How to: View ETW Data
Performance Report Column Definition