Profiling Silverlight Applications after installing Visual Studio 2010 Service Pack 1

Posted by mbcrump on Geeks with Blogs See other posts from Geeks with Blogs or by mbcrump
Published on Fri, 11 Mar 2011 14:42:08 GMT Indexed on 2011/03/11 16:10 UTC
Read the original article Hit count: 260

Filed under:

Introduction

Now that the dust has settled and everyone has downloaded and installed Visual Studio 2010 Service Pack 1, its 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 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.

SNAGHTML92dcca

Now, that we have verified you are on the most current release, let’s load up a Silverlight Application.

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.

image

Go ahead and click on CPU Sampling (recommended).

SNAGHTML9aa22a

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

SNAGHTML9c5dfa

We are going to leave the client as Internet Explorer.

SNAGHTML9eab10

Now, go ahead and click finish.

SNAGHTML9f2f8b

Now your Silverlight Application will launch.

image

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

SNAGHTMLa14c2f

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 IE8 and could find it by the title.

image

After you close your browser, you will notice it generated a report:

These files will end with a .VSP

image

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

image

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

image

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.

image

SNAGHTMLa935c2

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 its 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

© Geeks with Blogs or respective owner