mianlaoshu
mianlaoshu

Reputation: 2582

What the best way to measure app/activity startup time?

After googled this topic, I know there are several ways to measure the startup time of an android app.

  1. adb logcat -b events | grep am_activity_launch_time, see this post
  2. adb logcat -s ActivityManager:I | grep Displayed
  3. use reportFullyDrawn programmatically
  4. adb shell screenrecord --bugreport /sdcard/launch.mp4, to check video frame by frame, see this post
  5. adb shell am start -w packagename/MainActivity to check the output
  6. adb logcat -s Timeline:I, to checkout "App_transition_ready" and Activity_windows_visible in the output.

What is the most precise way to measure startup time of an Android app? What are the differences among them?

Upvotes: 1

Views: 4081

Answers (1)

Rahul Kumar
Rahul Kumar

Reputation: 5229

This is from Official Android Documentation

From API 19 onwards, 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. The elapsed time encompasses the following sequence of events:

  1. Launch the process
  2. Initialize the objects.
  3. Create and initialize the activity.
  4. Inflate the layout.
  5. Draw your application for the first time.

Log line looks like this

ActivityManager: Displayed com.android.myexample/.StartupTiming: +3s534ms

In order for this to work disable filters in logcat view in android studio because the system server, not the app itself, serves this log.

Check this official link for further explanation about different methods.

Upvotes: 3

Related Questions