Performance
Performance is a vague word if you don't define what you mean by performance, if it's plain computation performance Xamarin can be faster than Java depending on the nature of the computation.
Android nativly comes with multipe forms to execute code in:
- RenderScript (CPU and GPU)
- Java (SDK)
- C++ (NDK)
- OpenGL (GPU)
It is quite obvious that when executing code the more native the solution the faster it will be. A run-time based language will never beat a language that directly runs on the CPU.
But on the other hand if you want to measure real-life usage performance Java is propbaby going to be faster then Xamarin.
Xamarin and why it can be slower
When comparing Xamarin with plain old Java applications, performance can very well be faster for Xamarin as it can be slower.
In a real world example Xamarin applications are very likely to be slower than Java applications because many Android/Java (system) calls need to be delegated to and from the Xamarin run-time using so called bindings.
There are a few different types of bindings that are important to know:
- JNI (Java Native Interface): The binding used in many android applications to interface between Java code (SDK) and native C++ code (NDK).
- MCW (Managed Callable Wrappers): A binding that is available in Xamarin to interface from managed C# code to Java code (Android run-time).
- ACW (Android Callable Wrappers): A binding that is available in Xamarin to interface from Java code (Android run-time) to managed C# code.
More on MCW and ACW here: https://developer.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/part_1_-_understanding_the_xamarin_mobile_platform/
Bindings are in terms of performance very very costly. Invoking a C++ method from Java adds a huge overhead in calling time, calling a C++ method from within C++ is many many many times faster.
Someone did a performance test to calculate how many Java operations on average a JNI call costs: What is the quantitative overhead of making a JNI call?
But not only JNI calls are costly so are calls to and from MCW and ACW. Real world Xamarin applications make many calls using bindings and because of this real world usage of an Xamarin application can be (and will be in general) slower than a plain old Java application. However depending on how the Xamarin application was designed it is very likely that the user won't even notice the difference.
TLDR/Conclusion: Xamarin needs to using al sorts bindings, which are time costly.
Besides bindings, there are many other factors involved when talking about real-world performance, for example: size of the binary, loading the app in memory, I/O operations and many more. A blog post that investigates some of these things can be found here: https://magenic.com/thinking/mobile-development-platform-performance-part-2-native-cordova-classic-xamarin-xamarin-forms