I am trying to measure the time it takes to launch an App (cold startup) on Android.
As the official documentation states, that the startup time will be displayed in the logcat:
ActivityManager: Displayed com.android.myexample/.StartupTiming: +3s534ms
The problem I currently have is that startup times vary greatly. I tested on three different days à 10 times. These are the results:
- Day 1:
- Day 2:
- Day 3:
Does Android perform any optimization in the background for the App startup? Is there a way to reliably measure the startup time?
I haven't done any changes to the App in these three days. Before the testing, the phone was at 100% battery capacity and was cold to the touch (to eliminate the possibility of thermal throttling).
On day 2 and 3, I deleted the App, restarted the phone, reinstalled the App and tested again with the same results (day 2 was again ~900ms and on day 3: ~350ms).
Maybe it has something to do with the ART (Android RunTime) using JIT (just-in-time) and AOT (ahead-of-time) compiler?!
The app does not perform any network actions. At startup it only ready about 100 pictures from the internal storage and displays them in a Recycler View.
I used a Google Pixel 2 running on Android 9. The app is written in Java.