There are three environment variables needed for a .Net application you wish to profile. The profiler team has provided VSPerfCLREnv.cmd to set these variables for you. The switches for this helper file are:
for trace (instrumentation) profiling:
- /traceon for standard .Net profiling
- /tracegc to get allocation events as well
- /sampleon for attaching to a .Net application (this is not needed if the profiler is launching the application)
- Note: there is no /samplegc. To enable collection of allocation events for sampling, simply add the -gc flag to the VSPerfCmd.exe command when launching or attaching to the application
There are global versions of each of the above switches to set the environment need for profiling a managed service that is launched by the OS on startup, not the user (and hence the environment has to be set in the registry).
- /globaltraceon, /globaltracegc, and /globalsampleon
To delete these environment settings, simply use the /off or /globaloff switches.
- You do not need to do any of this if you are profiling an application by launching it with the Performance Explorer in the IDE. The Performance Explorer will set all of the needed environment settings for you.
- If the correct environment was not set during profiling, you will see a warning at analysis time and all of the managed function names will be blank
I hope this helps anyone exploring the command line capabilities of profiling a .Net application with Visual Studio Team System.
This posting is provided “AS IS” with no warranties, and confers no rights.