This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
The VSPerfCmd.exe Attach option begins sample profiling of the running process specified by the process ID (PID).
To use the Attach option, you must specify the Sample method in the Start option.
If the Start option was specified with the Crosssession option, any calls to VSPerfCmd /Attach or to VSPerfCmd /Detach must also specify Crosssession.
VSPerfCmd.exe /Attach:ProcessID [Options]
The process ID (PID) of the running process. The PID of a running process is listed on the Processes tab of Windows Task Manager.
The following VSPerfCmd options can be combined with the Attach option on a single command line.
Enables profiling applications in sessions other than the logon session. Required if the Start option was specified with the Crosssession option.
Initializes the command-line profiler session and sets the specified profiling method.
Specifies the version of the .NET Framework Common Language Runtime (CLR) to profile when more than one version is loaded in a profiling session. By default, the first loaded version is profiled.
Resumes (GlobalOn) or pauses (GlobalOff) profiling, but does not end the profiling session.
Resumes (ProcessOn) or pauses (ProcessOff) profiling for the specified process.
One of the following sampling interval options can be specified on the Attach command line. The default sampling interval is 10,000,000 processor clock cycles.
Specifies the number and type of the sampling interval.
Timer - Samples every
Cyclesprocessor clock cycles. If
Cyclesis not specified, 10,000,000 cycles are used.
PF - Samples every
Eventspage faults. If
Eventsis not specified, 10 page faults are used.
Sys - Samples every
Eventscalls to the operating system. If
Eventsis not specified, 10 system calls are used.
Counter - Samples every
Reloadnumber of the CPU performance counter specified by
FriendlyNamecan specify a string to use as the column header in profiler reports.
This example demonstrates how to attach to a running instance of an application with the process ID of 12345.
VSPerfCmd.exe /Start:Sample /Output:TestApp.exe.vsp VSPerfCmd.exe /Attach:12345