衡量应用/活动启动时间的最佳方式是什么?

问题描述:

经过Google搜索这个主题后,我知道有几种方法可以衡量Android应用程序的启动时间。衡量应用/活动启动时间的最佳方式是什么?

  1. adb logcat -b events | grep am_activity_launch_time,请参见this post
  2. adb logcat -s ActivityManager:I | grep的显示
  3. 使用reportFullyDrawn编程
  4. 亚行壳screenrecord --bugreport /sdcard/launch.mp4,逐帧检查视频帧,看this post
  5. 亚行外壳上午开始-w包名/ MainActivity检查输出
  6. adb logcat -s时间轴:我在输出中签出“App_transition_ready”和Activity_windows_visible。

什么是测量Android应用程序启动时间的最精确的方法?他们之间有什么不同?

这是从官方Android文档

从API 19日起,logcat的包括含有称为显示值的输出线。此值表示启动过程和完成在屏幕上绘制相应活动之间所经过的时间量。经过时间包括事件的顺序如下:

  1. 启动过程
  2. 初始化的对象。
  3. 创建并初始化活动。
  4. 膨胀布局。
  5. 第一次绘制您的应用程序。

日志行看起来像这样

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

为了这个工作在logcat的观点禁用过滤器在Android Studio中因为系统服务器,而不是应用程序本身,服务于这个日志。

请查看官方link了解有关不同方法的更多解释。