The low-rent guide to WPF profiling

Since I posted my initial article on command-line profiling, I've found a number of folks copy/paste off of it fairly often, with moderate success.  If you don't want to know all of the 'why's' and just want to get your profile, run the the following steps and copy/paste the commands.

1.  Install VSTS Team Suite or VSTS Team Edition for Developers, and open a command prompt.

2.  Setup your environment.  Copy/paste the following 4 commands into the command window.

set PATH=%PATH%;"C:\Program Files\Microsoft Visual Studio 8\Team Tools\Performance Tools"

VSPerfClrEnv.cmd /sampleon

vsperfcmd /start:SAMPLE /output:MyOutput.vsp

vsperfcmd /globaloff

3. Launch the profiler. You have 2 options -- attaching or launching. Use 'b' to measure startup costs, otherwise, you should normally use'a'.

a. Attaching (to measure anything after startup).

VERY IMPORTANT - Launch your application from the -command window- before running the following 2 commands. If you don't, managed code won't be profiled.

vsperfcmd /attach:MyTest.exe

vsperfcmd /globalon

b. Launching (to measure startup time)

vsperfcmd /globalon

vsperfcmd /launch:MyTest.exe

4. Now that profiling is enabled, perform the action you want to measure.

5. Stop profiling, shutdown the profiler, and generate your VSP.

vsperfcmd /globaloff

vsperfcmd /shutdown

6. Close your application.

7. Pack symbols. (Make sure your in the directory where your VSP lives, which is the same directory 'vsperfcmd /start' was issued from)

xcopy /E "C:\Documents and Settings\timothyc\My Documents\Visual Studio 2005\Projects\MyTest\MyTest\bin\Release\*.PDB" .

vsperfreport /summary:all /packsymbols MyOutput.VSP