Xamarin.Forms: what about performance agains Xamarin.iOS “Classic”? Is it faster or slower?

As of the 1st of August, 2014, Xamarin issued the version 1.2.2 of the platform (version 1.2.1 proved really buggy. Luckily, the Xamarin guys patched it well).

I can now test how Xamarin Forms performs (in terms of speed) compared to a “classic” Xamarin iOS development.

I did a very similar test to the one we did on Android.

It is, in “Release” mode:

1. I create a scrollview for 50 times.

2. To every scrollview I add: 20 labels, 20 textfields with a placeholder, 20 buttons with an event handler.

3. all the labels, textfields and placeholders are removed from the scrollview and destroyed (except for the 100th iteration)

4. the scroll is removed from the root view (except for the 50th iteration)

Xamarin.iOS “Classic” (with iOS designer on visual studio, “release” configuration):

average of 3710 milliseconds on the iPhone 5 64 bit “simulator”

average of 14050 millseconds on the iPhone 5 “classic” device

Xamarin.Forms “Classic” (with iOS designer on visual studio): 

average of 141 milliseconds on the iPhone 5 64 bit “simulator”

average of 609 millseconds on the iPhone 5 “classic” device

 

So, in terms of how fast it is, on iOS Xamarin Forms beats Xamarin “classic” as it happens with Android, at least when it comes to standard UI buttons, labels and textfields.

This is the code:

“iOS Classic”

Code to test classic iOS development with Xamarin, in particular creation and destruction of subviews

Xamarin.iOS speed test code

Xamarin.Forms

Code to test performance of Xamarin Forms on iPhone and iPad

Xamarin.Forms test code

Xamarin Forms performance compared to “Classic” Xamarin development

How does the Xamarin Forms technology compare to the “classic” Xamarin technology on Android?

The “forms” technology has been out since May 28th, 2014 (http://blog.xamarin.com/announcing-xamarin-3/)

On July, 13th, 2o14, the 1.2.1 version of Xamarin.Forms was issued as a hotfix to 1.2.0.

The pros and cons of the philosophy of cross-platform “Forms” will not be discussed now. Let us evaluate the performance of the “forms” paradigm to check if it is as fast as the “old” one.

Of course, I focused on the UI, because the rest of the platform does not change (much).

I tested Android and iOS UI performance (i.e.: the speed) on:

– Genymotion emulator for Android (based on VirtualBox)

– Android “official” emulator (4.4.2 on Intel fast HAXM)

– Android machine (4.1)

In a later post, you will see the same with:

– iOS simulator

– iPhone 5

What did we precisely test?
We tested what, in our experience, is the hardest UI task: the dynamic creation and destruction of elements.

The task is the following:

  • Create (or individuate) a “main view”
  • Add a scrollview to the mainview
  • Add a vertical “stack” layout view to the scrollview
  • Add dynamicaly 100 labels, 100 textfields, 100 buttons with click event handlers
  • delete all of the labels and textfields except for two
  • add another label
  • destroy the “main view”, re-do another four times

At least part of these tasks is asynchronous, so these tests cannot be considered as a reliable proof that Xamarin.forms is faster than “classic” Android development, but… I am very confident now.

How did Xamarin.Forms perform on Android?
Very well, and I have to say surprisingly because it’s supposed to be an abstraction on an abstraction (it probably isn’t!).

The new technology seems to be at least as fast as the old one. Xamarin.Forms seems to have speed on its side.

I do have to say that of course we could not do the exact same things on the two platforms (for instance: in one platform you can plainly replace the child of a view; in the other, you first have to remove the children).

I tried to hone the code so that it gave the best results for both platforms.

GenyMotion: Xamarin Forms (KitKat on windows, i5, 8Gb) is better than Xamarin “classic” (and Genymotion is better than the Intel emulator)

Xamarin.Forms: average of ten tests: 195  milliseconds (three times faster than before, apparently)

Xamarin Android “classic”: average of ten tests: 773  milliseconds

Intel Android Emulator (KitKat on windows, i5, 8Gb): Xamarin Forms is still better than Xamarin “classic” 

Xamarin.Forms: average of ten tests: 566 milliseconds (still four times faster than before, apparently)

Xamarin Android “classic”: average of ten tests: 2100 milliseconds

A real Android device: Xamarin Forms is still better than Xamarin “classic” 
We also tested the performance of Xamarin.forms on an Android device (a 7 inch Samsung Tab2)

Xamarin.Forms: average of ten tests: 302 milliseconds (still four times faster than before, apparently)

Xamarin Android “classic”: average of ten tests: 909 milliseconds

The Code for XAMARIN FORMS:

the code for Xamarin forms performance test

Xamarin forms speed test

 

The Code for XAMARIN “Classic”:

the code to test the speed of Xamarin Android

Xamarin classic Android speed test