APP启动性能度量指标
- 首次安装启动:首次安装会耗费较多的时间初始化,比如补丁下载、缓存数据
- 冷启动:进程不存在(谷歌标准5s)
- 暖启动:进程存在,界面不存在(谷歌标准2s)
- 热启动:界面对象仍然存在,只是从后台前置到前台(谷歌标准1.5s)
- 首屏启动:第一屏加载完整
UI性能检测常用办法
- adb logcat
- 录屏+视频拆帧
- uiautomator等自动化工具200ms巡检界面变化
- traceview
- 硬埋点
logcat中的性能数据
package=edu.yjyx.student
adb shell pm clear $package # 清理缓存数据
adb shell am force-stop $package # 停止进程
adb shell am start -S -W $package/edu.yjyx.student.module.main.ui.SplashActivity # 启动app
adb logcat|grep -i displayed # 获取数据
打印的结果为:
Stopping: edu.yjyx.student
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=edu.yjyx.student/.module.main.ui.SplashActivity }
Status: ok
Activity: edu.yjyx.student/.module.main.ui.SplashActivity
ThisTime: 769
TotalTime: 769
WaitTime: 779
Complete
ThisTime: 该activity启动耗时
TotalTime: 应用自身启动耗时=ThisTime+应用application等资源启动时间
WaitTime: 系统启动应用耗时=TotalTime+系统资源启动时间
录屏拆帧
adb shell screenrecord --bugreport --time-limit 30 data/local/tmp/test.mp4
adb pull /data/local/tmp/test.mp4
ffmpeg -i test.mp4 test.gif
ffmpeg -i test.mp4 -r 10 frames_%03d.jpg # 0.1秒截一次