How to Profile IIS Express with Visual Studio 2010 SP1
While IIS Express support shipped in Visual Studio 2010 SP1, unfortunately profiling code running in IIS Express does not just work out of the box. The issue is that the profiler does not “know” how to setup and launch the IIS Express process to enable the various profiling methods. If this is a blocking issue for you, fortunately this can be manually worked around to profile IIS Express.
The instructions for how to do this, vary depending on the method of profiling you would like to use, and the target framework
CPU Sampling:
- If you’re profiling .NET 4.0 after you’ve launched your site in IIS Express, manually attach to the IISExpress.exe process (Analyze -> Profiler -> Attach/Detach…) and you will be collecting CPU sampling data
- · If you’re profiling .NET <= 3.5:
- From a Visual Studio command prompt, type:
- vsperfclrenv /sampleon
- devenv
- From the instance of Visual Studio that launches, launch your site in IIS Express and manually attach as in the step for profiling .NET 4.0
- From a Visual Studio command prompt, type:
.NET Memory Profiling (Sampling)
- From a Visual Studio command prompt, type:
- vsperfclrenv /<memory option you want—see vsperfclrenv documentation for options>
- devenv
- From the instance of Visual Studio that launches, launch your site in IIS Express and manually attach as in the CPU sampling scenarios
Instrumentation (including .NET memory instrumentation)
- From a Visual Studio command prompt, type:
- For method timing: vsperfclrenv /traceon
if you want memory, see vsperfclrenv documentation for options - devenv
- vsinstr <your binaries that will run inside IIS Express>
- vsperfcmd /start:trace /output:<report name>
- For method timing: vsperfclrenv /traceon
- From the instance of Visual Studio that launches, launch your website in IIS Express and run your scenario
- From the command prompt type: vsperfcmd /shutdown
- Close IIS Express
- Open the resulting .vsp file in Visual Studio
Resource Contention Profiling
- Launch your website in IIS Express
- From a Visual Studio Command Prompt:
- vsperfcmd /start:concurrency,resourceonly /output:<report.vsp>
- vsperfcmd /attach:<IISExpress.exe’s PID>
- Run your scenario
- vsperfcmd /shutdown
- close IIS Express
- Open the resulting .vsp file in Visual Studio