How to use Windows Azure Profiling Tools in Visual Studio

Just recently, I have been looking for a tool to profile my Windows Azure application when it runs on Azure. Yeah most browsers have that F12 dev tools, but they just won’t cut it for what I want. What I didn’t know, is that I didn’t look very far. As it so happens, the Windows Azure SDK includes a profiler that will profile your app (including code) when it runs on Windows Azure.

Was a bit hesitant so I decided to test it myself.

Steps would be:

  1. Create an azure worker role with two functions, one is okay, and the other is really bad (performance hog)
  2. Deploy it and have it profiled
  3. Hopefully the profiler will be able to identify which function is better, or which one needs improvement

Sounds sensible enough J

So I fire up Visual Studio and create a worker role.

So, what to put.. friend of mine Jon Limjap pointed me here and here is what I have now:

///
<summary>


/// Function I got from Stackoverflow


///
</summary>


///
<param name=”stringLength”></param>


///
<returns></returns>


private
string RandomStringGood(int size)

{

System.Text.StringBuilder builder = new
StringBuilder();


Random random = new
Random();


char ch;


for (int i = 0; i < size; i++)

{

ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));

builder.Append(ch);

}

 


return builder.ToString();

}


///
<summary>


/// modified it to be a bad function (my specialty hahaha)


///
</summary>


///
<param name=”size”></param>


///
<returns></returns>


private
string RandomStringBad(int size)

{


String builder = string.Empty;


Random random = new
Random();


char ch;


for (int i = 0; i < size; i++)

{

ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));

builder += ch;

}

 


return builder.ToString();

}

 

Then I call them

public
override
void Run()

{


// This is a sample worker implementation. Replace with your logic.


Trace.WriteLine(“$projectname$ entry point called”, “Information”);

 


while (true)

{

RandomStringBad(1);

RandomStringGood(1);


Thread.Sleep(10000);


Trace.WriteLine(“Working”, “Information”);

}

}

 

Short, simple and should do the job (fingers crossed)

So, then I use the profiling tool.. I deploy this to my Azure Subscription using Visual Studio

With these settings

I checked Enable Profiling then published it.

Some waiting involved..

Took while but when it is ready..

You can start profiling the workerrole

Again some waiting

Then I saw something that caught my attention

So I guess there is something that will need to be done with the symbols. But my test app is just a barebones app so I guess there is no need to worry about that just now.

I tried visiting the browser version of the Azure management portal.. and it showed activity

Annndddddd… here are the results!

The profiler indicates that RandomStringBad uses more resources than RandomStringGood!

And clicking on that item on the list takes me to the code

So I guess it works!

About these ads
This entry was posted in Computers and Internet. Bookmark the permalink.

3 Responses to How to use Windows Azure Profiling Tools in Visual Studio

  1. Pingback: Friday Five–September 21, 2012 | UpSearchBI

  2. Pingback: Friday Five–September 21, 2012 | UpSearchSQL

  3. Pingback: Friday-Five Series: Featuring Blog Posts by MVPs Serena Yeoh, Eduardo Lorenzo & Nguyen Thuan « SEA MVPs Blog-A-Holic

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s