Saturday, September 18, 2010

Timing tests on Azure

In order to test the performance of your app on Azure, you really need to test on Azure.

This is especially the case when your app needs to talk to local SQL Azure, Table, Blob, and Queue resources - you can't test the performance of these:
- when you are running the storage on the DevFabric
- when you are running on the real storage, but with your app on a dev machine outside of the data center

When you are running on Azure, then how do you get your results out.

Well, to start with I've just used some simple tests using System.Diagnostics.StopWatch:

At the start of the method to be tested
            List<KeyValuePair<string, long>> times = new List<KeyValuePair<string, long>>();
            times.Add(new KeyValuePair<string, long>("Original", 0L));
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();

Half way through:
            times.Add(new KeyValuePair<string,long>("namedPoint", timer.ElapsedMilliseconds));

And at the end:
            times.Add(new KeyValuePair<string, long>("timeToEnd", timer.ElapsedMilliseconds));

            foreach (var t in times)
                System.Diagnostics.Trace.TraceError(string.Format("{0}:{1}", t.Value, t.Key));

This then uploads the results to Azure Diagnostics - currently Trace is routed to Table storage.

Obviously this is only a temporary solution - only suited for simple methods, and you have to remove this code for Production.

No comments:

Post a Comment