I've been investigating performance tuning my Xamarin Forms application when running on an Android device using an Intel Atom CPU.
The largest performance I'm currently seeing is when loading a DataTemplate to set as the Content of a ContentView, this DataTemplate then dynamically loads other controls and DataTemplates within it to produce the UI of the application.
Running on this device from the signed APK archive, I am seeing the time taken from tapping on the screen to finish loading the completed UI of 3.9 seconds.
However, if I deploy the application from Visual Studio then run it on the device without the debugger attached, this same process drops to around 1.5 seconds.
It seems to be reliably triggered by the "Use Shared Runtime" option within the project properties. With this ticked I consistently see this process taking about 1.5 seconds, with it unticked it's up to ~3.9 seconds. This is the same regardless of application has been built in debug or release mode and regardless of the other settings within the project properties.
This particular scenario is the worst performing part, however I see all UI loading/layout processes improve by a similar ratio, displaying another view drops from 1.5s to 0.8s and so on.
As I am unable to create an archive with this setting ticked, what could be causing this change in performance and how do I get this performance replicated with it unticked?
I am running Xamarin.Forms 3.4.0.1008975, VS2017 15.9.4 and Xamarin.Android 9.1.4.2
答案 0 :(得分:0)
勾选Use Shared Runtime
会在“高级”窗口的Supported Architectures
选项中选择所有体系结构。
取消选中它将删除除armeabi-v7a
以外的所有条目,这意味着不再选择x86
。由于它现在在x86 CPU上运行ARM应用程序,因此导致该应用程序运行速度较慢。
确保取消选中x86
后在Use Shared Runtime
上打勾,以在基于x86的设备上运行时提供所需的性能。