Click here to Skip to main content
15,612,351 members
Articles / Desktop Programming / XAML
Posted 22 Dec 2010


12 bookmarked

Performance Wizard for Silverlight

Rate me:
Please Sign up or sign in to vote.
4.71/5 (5 votes)
22 Dec 2010CPOL3 min read
Profile Silverlight applications performance directly through Visual Studio


I had written this article on my blog and thought of posting it on CodeProject too.


Microsoft has released the first service pack for Visual Studio 2010. Although the service pack is marked as beta it comes with a “go live” license. Along with it, two other service packs are released - Team Foundation Server 2010 SP1 Beta and .NET 4.0 SP1 Beta. For Silverlight developers, they have packed two updates in the Visual Studio 2010 SP1 Beta.

  1. Silverlight 4 tools for Visual Studio 2010: “The Silverlight 4 tools are now included along with Silverlight 3 support”, all it means is that you will not have to install Silverlight 4 tools separately.
  2. Performance Wizard for Silverlight: This will enable the users to profile the Silverlight application performance directly through Visual Studio, user can create profiling reports and save them.

You can get the download links from Brian blog, he has nicely detailed all important updates in the service packs

Once you have downloaded the web installer, be patient as the install will take some time to download the packages and install. For me, the process took around an hour from start to finish. After successful installation, you will be asked to restart your computer. Now your Visual Studio is all set to start profiling your Silverlight application using the wizard.

The Performance Wizard is very simple. Let us go step by step through it, open an existing Silverlight project or create a new project. To launch the ‘Performance Wizard’, go to the main menu find Analyze –> Launch Performance Wizard…


Performance wizard page 1 of 3 should be displayed, CPU Sampling must be selected by default if not the check mark the radio button before CPU Sampling.


Performance wizard page 2 of 3 - on this page you will find a list of projects depending on the structure of your solution. Typically for a Silverlight project, you will find the Silverlight application and the web application in the list, select your Silverlight application and click the ‘Next’ button.


Performance wizard page 2 of 3 is just a summary that says all the information needed has been collected. Make sure that on this page you have the check mark on the check box labelled as Launch profiling after the wizard finishes. When you click finish, the application should open in your default browser.


If you are not running as administrator, you might get an error saying “Unable to open profiler driver, would you like to upgrade credentials ..“ . Just click ‘yes’ and provide admin credentials if needed.


Once the above steps are done, the Performance Explorer with be populated with a structure similar to the image below. The performance wizard has created two folders, Reports and Targets.


Ok, now let's do a simple performance test. Let us create a simple application and see how the performance report looks like. Create a Silverlight application. In your main page, add a button and on the click of the button, we should have a function that does some kind of CPU intensive activity. I have simply created a nested loop to keep the CPU busy for a while, but you can write any code that will be CPU intensive.

private void Button_Click(object sender, RoutedEventArgs e) 
  for (int i = 0; i < 100000; i++) 
     for (int j = 0; j < 10000; j++) 

Now follow the steps shown above to generate a profiling report using the wizard, run the project and click on the button a couple of times and then close the browser. Visual Studio will bring up the visual report based on the samples collected during the performance analysis. THe below figure shows the result of my test, one can clearly identify in the graph the spike in CPU during the first and second click. An interesting fact is that Studio will automatically show a call tree of the method that is expensive in terms of resources. For our case, the event handler Button_Click() does an expensive for loop and Studio was able identify the method and display the call hierarchy.


Points of Interest


  • 22nd December, 2010: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Software Developer (Senior)
India India
My name is Vikas Amin ,my childhood dream was to be a rocket scientist so many times ended with burned hand meshing with firecracker rockets. Now I mesh with computer's using C#,VC++,C,C++,VB,ASP,Silverlight,WPF,WCF,Assebly language some vbscript and javascript.

Comments and Discussions

Generalnice one Pin
Pranay Rana23-Dec-10 21:53
professionalPranay Rana23-Dec-10 21:53 
GeneralRe: nice one Pin
vikas amin28-Dec-10 8:00
vikas amin28-Dec-10 8:00 
GeneralMy Vote of 5 Pin
RaviRanjanKr23-Dec-10 3:34
professionalRaviRanjanKr23-Dec-10 3:34 
GeneralRe: My Vote of 5 Pin
vikas amin28-Dec-10 8:00
vikas amin28-Dec-10 8:00 
GeneralMy vote of 5 Pin
prasad0222-Dec-10 18:32
prasad0222-Dec-10 18:32 
GeneralRe: My vote of 5 Pin
vikas amin23-Dec-10 3:17
vikas amin23-Dec-10 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.