VS2010 SP1 New Features: Performance Wizard Support for Silverlight
Windows: Alt, N, Z
Menu: Analyze | Launch Performance Wizard
Command: Analyze.LaunchPerformanceWizard
SKU: Premium, Ultimate
Versions: 2005, 2008, 2010
Languages: C#, VB
Code: vstipTool0128
This post represents a new path I’m taking with Visual Studio Tips and Tricks. In the past, I have limited the information to just Visual Studio <version> Professional. Now I will be including Premium and Ultimate in the tips going forward. Because of this change, I am now adding Stock Keeping Unit(SKU) information in the summary to make it clear to what SKU of VS the tip will be applied.
Silverlight 4 profiling has been around quite a while in Visual Studio 2010 (see https://blogs.msdn.com/b/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx) however it was not well integrated into the UI until Service Pack 1. My goal isn’t to dig into the details of performance profiling here but rather show the UI integration that now exists when analyzing Silverlight applications. I will show how to get metrics when just looking at the Silverlight application alone and then how to look at ASP.NET and Silverlight performance combined.
Silverlight Only
You can quickly and easily get performance metrics, just open any Silverlight application in Solution Explorer then go to Analyze | Launch Performance Wizard on the menu bar:
For this example, just keep CPU Sampling selected and click Next:
Select the Silverlight project you want to analyze and then click Next and then click Finish. It will launch the application and start collecting profile information:
Use some of the features of the application for a bit then close the application. Visual Studio will generate a report and give you the performance data (small sample of the report shown here):
Silverlight and ASP.NET
As noted by Andrew Hall on the Profiler Team Blog: “Unfortunately there is a limitation where we cannot automatically attach to multiple processes on launch from inside Visual Studio, so you are still unable to profile ASP.NET and Silverlight at the same time without manually attaching to Internet Explorer after launch. Fortunately, this is relatively simple.”
I will review the steps from the preceding link here for you. Assuming you have a an ASP.NET application with a Silverlight application hosted in one of the pages, go to Analyze | Launch Performance Wizard on the menu bar and choose CPU Sampling as shown earlier then click Next. Choose the ASP.NET application and start collecting data.
Once you are collecting data on the ASP.NET application then go to Performance Explorer (View | Other Windows | Performance Explorer) then click the Attach/Detach button:
Note: You may need to switch away from the .VSP file that is collecting data. When I tried this on my machine the menu item was disabled until I switched away from it to another document.
Attach to the IE session that is running your Silverlight application:
Note: You may not see a Window Title like I have here. If you can’t figure out which session is the correct one you may need to take additional steps detailed below to find the ProcessID (PID) for the application.
Finding Your Silverlight Application
If you need to find your Silverlight application running in IE then you will need a refined process tool. I’m going to use Process Explorer from Sysinternals (https://technet.microsoft.com/en-us/sysinternals/bb896653.aspx). Open Process Explorer and position your windows so you can see Process Explorer and your Silverlight Application running in IE. Click and drag the target icon over the Silverlight application:
This will reveal the correct process and PID in Process Explorer:
Go to Performance Explorer in Visual Studio and click the Attach/Detach button then select the process with the PID you just obtained to collect performance metrics on your Silverlight application:
Now you are collecting data on your ASP.NET application and your Silverlight application.