Response time difference between Windows Azure extra small and small instances

This was originally posted on my old blog.

When Foundbite was in its very early stages I was using the Windows Azure Extra Small instance to host the API and with a very small number of beta testers the response time was more than fine, though did fluctuate a lot.

As the beta expanded and because I get a free allowance for Windows Azure through BizSpark, I decided to move my web role up to a Small Instance. Unlike the Extra Small, the Small instance is not shared with others and I was curious to see the response time gains that could be had. Turns out, they are quite significant:

Although I realise this isn’t a completely fair test as the number of requests and type of requests vary, it’s quite apparent that the response time dropped significantly. I hadn’t expected such a clear distinction.

You can see the difference in size between instances here, I have no idea how much an A7 costs but wow that’s a lot of power!

If you need help choosing an instance size, this article is also really useful.

The above graph was made using New Relic Performance Monitoring which you can get for free using your Azure subscription.


Lessons Learnt Using the Windows Phone Camera API

I’ve been working with the Windows Phone camera API (PhotoCaptureDevice) a lot recently for Foundbite, some of the things I’ve learnt:

Not every Windows Phone has flash

I didn’t realise this until recently when testing with the cheap as chips Nokia Lumia 520. It’s a great device for the price but you need to add a check to your camera code to make sure other flash modes are available before manipulating it.

Here’s a method to get the available flash states and another to check if flash is available for the current device (ie: if there is one or less flash states).

public bool IsFlashAvailable()
List<FlashState> flashStates = GetAvailableFlashStates().ToList();
return (flashStates.Count > 1);

public IReadOnlyList<FlashState> GetAvailableFlashStates()
IReadOnlyList<object> rawValueList = PhotoCaptureDevice.GetSupportedPropertyValues(Device.SensorLocation, KnownCameraPhotoProperties.FlashMode);
List<FlashState> flashStates = new List<FlashState>(rawValueList.Count);foreach (object rawValue in rawValueList) flashStates.Add((FlashState)(uint)rawValue);
return flashStates.AsReadOnly();

Update #1: Jay Benett ponts out that this can be done in a far simpler way than I have using LINQ’s .Any()

Update #2: Just realised this update 1 method won’t work as even if there isn’t a flash on the device there will still be FlashState.Off in the list.

Update #3:After more discussion, it turns out there is a way to do it using Jay’s method: I’m going to stop updating this post now.

In some regions the camera shutter sound can’t be turned off

Foundbite allows you to take a picture at the same time as recording audio so it wouldn’t be ideal if you could hear the shutter sound in every sound clip. It is possible to turn the sound off but in some regions of the world it’s a legal necessity to have this sound on.

It’s therefore a necessity to check that you can turn the sound off before doing so:

private void disableShutterSound()
if (!(bool)this.Device.GetProperty(KnownCameraGeneralProperties.IsShutterSoundRequiredForRegion))
this.Device.SetProperty(KnownCameraGeneralProperties.PlayShutterSoundOnCapture, false);

It’s possible to turn off the flash that happens when you focus the camera

This setting is called the FocusIlluminationMode and can easily be changed, much like FlashMode, between Auto, On and Off.

Here’s the code to get the current value and change it:

public FocusIlluminationMode GetCurrentFocusIlluminatonMode()
return (FocusIlluminationMode)(uint)Device.GetProperty(KnownCameraPhotoProperties.FocusIlluminationMode);

public void SetIlluminationMode(FocusIlluminationMode mode)
Device.SetProperty(KnownCameraPhotoProperties.FocusIlluminationMode, mode);

It’s worth nothing that you should check the flash is available before changing this mode too!
Hopefully these will be helpful and save some time for others playing around with the camera.

Recent Reads

Some books I’ve read, and enjoyed recently….

The Hundred Year Old Man Who Climbed Out the Window and Disappeared. Jonas Jonasson (translated by Rod Bradbury)

A funny and heart-warming story about Allan Karlsson and his flight from an old people’s home on his 100th birthday. Drug dealers, explosions and communist dictators are all involved and the way Jonasson interlaces Allan’s story with almost every pivotal event of the 20th Century is brilliant.A geriatric Forrest Gump if you will.

The translation is just brilliant, you’d have no idea it was originally written in Swedish. The author is also a pretty interesting fellow.

One of the best books I’ve read in a long while.


Bad Lands. Tony Wheeler

Tony Wheeler, founder of Lonely Planet, recounts his travels to some of the most dangerous, repressive and least travelled countries in the world.Countries featured include; North Korea (of course), Iraq, Afghanistan, Saudi Arabia, Albania and Burma.

It makes for an interesting read with lots of anecdotes and short history lesson about each country. I’d recommend the book, but can’t say I’ll be visiting any of the countries soon.


Life After Death. Damien Echols

In 1994, Damien Echols, along with two others, was convicted of murdering three young boys as part of a “Satanic Ritual” — a crime he didn’t commit. They became known as the West Memphis Three. Released after over 18 years on Death Row this is a honest, open and often terrifying account of his time there.

The injustices Damien and the other two boys experienced often saw my jaw hitting the floor, but the love of a woman he’d never met, Lorri Davis, who mounted a campaign to release him restored my faith in humanity.

Having previously known nothing about this case I caught a Guardian article about him and bought the book. I’m glad I did, and will probably try to check out several of the documentaries that have been made about the case now.


The Eagle Has Landed. Jack Higgins

Having seen and enjoyed the 1976 film starring Michael Caine, I picked up this book for cheap on the Kindle store.

It’s by no means a literary classic but the story of a crack German parachute regiment taking over a sleepy East Anglian town to try and assassinate Winston Churchill is a classic war caper and an entertaining read. Reminded me of my childhood passion for Commando Comics.


Navigation Strings in Windows Phone Apps

Whilst hacking away a few weekends ago at Hacked with the eminent Windows Phone developers Jay and Scott, I noticed Scott using a static constants class to store the navigation strings of pages in the app we were developing. I’d always hard-coded my navigations strings in the normal way, like so:

NavigationService.Navigate(new Uri("/MainPage.xaml", Urikind.Relative));

I’d always run into some difficulties when renaming or getting rid of a page in the app – bloody navigation exceptions.

So when I saw Scott using the constants in our hack I converted Foundbite to do the same and will be doing it this way in the future. Here’s how it works:

You have a static class to store your page relative strings for each page:

public static class WP8Constants
public const string MAIN_PAGE = "/MainPage.xaml";
public const string PROFILE_PAGE = "/ProfilePage.xaml";
public const string LARRY_PAGE = "/LarryPage.xaml";
public const string JIMMY_PAGE = "/JimmyPage.xaml";
public const string ELAINE_PAIGE = "/ElainePaige.xaml";

You have another static helper class to do the navigation for you:

public static class NavigationHelper
public static void Navigate(PhoneApplicationPage page, string navigateTo)
page.NavigationService.Navigate(new Uri(navigateTo, UriKind.Relative));

Then when you want to navigate to a page, it’s nice and easy:

NavigationHelper.Navigate(page, WP8Constants.LARRY_PAGE);

There’s less typing, Intellisense will give you your list of available pages AND should you want to interchange a page or change a page’s location you just need to change it your constants class.
Things like this make development just that little bit easier. 

Windows Phone Beta Email Helper

Whilst running the Foundbite beta I found it a little bit annoying importing users that have signed up (through my Mailchimp mailing list) by copying and pasting from an open CSV in Excel and then having to add add a semi-colon at the end of each line in the Windows Phone developer centre.

Thankfully the beta has been pretty well received and after carrying out this laboured process several times, it dawned on me that I could probably make a program to do this for me. So I did.  True story.

With the helper you can import a csv file of emails from any source Excel, Mailchimp, Google Docs etc. and it will churn out a list of comma delimited emails. I also added some email verification code to ensure that no invalid emails get added.

Dead simple really.

Open CSV file containing email data and rename column to “email”:

Windows Phone Beta Email Helper

Open the Helper, select the csv file and there you are:

Windows Phone Beta Email Helper

If there’s an invalid email, it’ll flag it up:


Any programmer worth his/her salt can probably make it in far less time than me, but since I have, why bother?

Download a .zip containing  the Windows Forms Helper