APP啟動(dòng)性能度量指標(biāo)
- 首次安裝啟動(dòng):首次安裝會(huì)耗費(fèi)較多的時(shí)間初始化钾埂,比如補(bǔ)丁下載科平、緩存數(shù)據(jù)
- 冷啟動(dòng):進(jìn)程不存在(谷歌標(biāo)準(zhǔn)5s)
- 暖啟動(dòng):進(jìn)程存在,界面不存在(谷歌標(biāo)準(zhǔn)2s)
- 熱啟動(dòng):界面對(duì)象仍然存在瞪慧,只是從后臺(tái)前置到前臺(tái)(谷歌標(biāo)準(zhǔn)1.5s)
- 首屏啟動(dòng):第一屏加載完整
UI性能檢測(cè)常用辦法
- adb logcat
- 錄屏+視頻拆幀
- uiautomator等自動(dòng)化工具200ms巡檢界面變化
- traceview
- 硬埋點(diǎn)
logcat中的性能數(shù)據(jù)
package=edu.yjyx.student
adb shell pm clear $package # 清理緩存數(shù)據(jù)
adb shell am force-stop $package # 停止進(jìn)程
adb shell am start -S -W $package/edu.yjyx.student.module.main.ui.SplashActivity # 啟動(dòng)app
adb logcat|grep -i displayed # 獲取數(shù)據(jù)
打印的結(jié)果為:
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啟動(dòng)耗時(shí)
TotalTime: 應(yīng)用自身啟動(dòng)耗時(shí)=ThisTime+應(yīng)用application等資源啟動(dòng)時(shí)間
WaitTime: 系統(tǒng)啟動(dòng)應(yīng)用耗時(shí)=TotalTime+系統(tǒng)資源啟動(dòng)時(shí)間
錄屏拆幀
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秒截一次