What is the most precise way to measure startup time of an Android app?
By startup time I mean the difference between 2. and 3. :
So I basically need to somehow get time elapsed since JVM started and log it.
On the App start-up time page inside Android Vitals (on Google Play console), you can see details about when your app starts slowly from cold, warm, and hot system states. These metrics are automatically calculated, without any development effort.
How to retrieve TTID. In Android 4.4 (API level 19) and higher, logcat includes an output line containing a value called Displayed . This value represents the amount of time elapsed between launching the process and finishing drawing the corresponding activity on the screen.
App start traceThis trace measures the time between when the user opens the app and when the app is responsive. In the console, the trace's name is _app_start . The collected metric for this trace is "duration".
There's no reliable way to detect first run, as the shared preferences way is not always safe, the user can delete the shared preferences data from the settings! a better way is to use the answers here Is there a unique Android device ID? to get the device's unique ID and store it somewhere in your server, so whenever ...
I understand I am too late to answer, nonetheless, this precisely answers the question.
This information gets logged on Logcat by default for API version 19 or higher.
From Android 4.4 (API level 19), logcat includes an output line containing a value called Displayed. This value represents the amount of time elapsed between launching the process and finishing drawing the corresponding activity on the screen.
ActivityManager: Displayed com.android.myexample/.StartupTiming: +3s534ms
The key is looking for it in the right place -
If you’re tracking logcat output from the command line, or in a terminal, finding the elapsed time is straightforward. To find elapsed time in Android Studio, you must disable filters in your logcat view. Disabling the filters is necessary because the system server, not the app itself, serves this log.
The extracts are from the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With