Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Profiling Silverlight Applications After Installing Visual Studio 2010 Service Pack 1

0.00/5 (No votes)
11 Mar 2011 1  
Here is an easy way to profile your Silverlight Applications after installing Visual Studio 2010 Service Pack 1

Introduction

Now that the dust has settled and everyone has downloaded and installed Visual Studio 2010 Service Pack 1, it's time to talk about a new feature included that will help Silverlight developers profile their applications. Let’s take a look at what the official documentation says about it:

Performance Wizard for Silverlight – taken from VS2010 SP1 KB.

Visual Studio 2010 SP1 enables you to tune the Silverlight application performance by profiling the code. A traditional code profiler cannot tune the rendering performance for Silverlight applications. Many higher-level profilers are added to Visual Studio 2010 SP1 so that you can better determine which parts of the application consume time.

So, How Exactly Do You Do It?

After you finish installing VS2010 SP1, make sure it took by going to Help –> About. You should see SP1Rel under Visual Studio 2010 as shown below:

1.png

I’m going to take my hobby Silverlight project that I created a month or so ago. The reason that I’m picking this project is that I didn’t focus so much on performance as it was just built for fun and to see what I could do with Silverlight. I believe this makes the perfect application to profile.

After the project is loaded, click on Analyze, then Launch Performance Wizard.

2.png

Go ahead and click on CPU Sampling (recommended).

3.png

You will notice that it asks which application to target. By default, it will select the .Web project in a Silverlight application. Go ahead and leave the default Web Project checked.

4.png

We are going to leave the client as Internet Explorer.

5.png

Now, go ahead and click finish.

6.png

Now your Silverlight Application will launch.

7.png

While your application is running, you will see the following inside of Visual Studio 2010.

8.png

Here is where you will need to attach your Silverlight Application to the web application that is current being profiled. Simply click on the Attach/Detach button below and find your application to attach to the profiler. In my case, I am using Internet Explorer 8 and could find it by the title.

9.png

After you close your browser, you will notice it generated a report (files end in a .VSP).

10.png

If you click on the .VSP, you will see it generated the following report:

11.png

We could turn off “Just My Code”, but it may pick up things that we didn’t want to profile as shown below:

12.png

One other feature to note is that you may want to export the data to a CSV or XML. You can do that by looking at the toolbar and clicking the button highlighted below:

13.png

14.png

Conclusion

The profiler for Silverlight is a great addition to an already great product. So before you ship a Silverlight Application, run it through the profile and see what comes up. Since it's included and free, I can’t see a reason not to do this. Thanks again for reading and I hope you subscribe to my blog or follow me on Twitter for more Silverlight/WP7 fun.

alt Subscribe to my feed

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here