0

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:
    • ~1100ms
  • Day 2:
    • ~900ms
  • Day 3:
    • ~350ms

My Question:
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.

2
  • run-time measurement of Java based programs in generally is not very easy (JIT, garbage collector, ..). Additionally you have to consider that your app may be executed concurrently by other apps or other services starting-up. Therefore measuring execution time is IMHO meaningless, better measure CPU time. Also when your app is loading something from internal storage I assume you use other services such as MediaStore which itself can have different execution timing. If you really need a timing value, measure may be 100 boot cycles and take the median.
    – Robert
    Dec 16, 2020 at 12:01

0

You must log in to answer this question.

Browse other questions tagged .