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:
Xamarin forms speed test
The Code for XAMARIN “Classic”:
Xamarin classic Android speed test