APP启动性能分析

254 阅读1分钟

使用adb logcat进行性能分析

1、adb shell 进入手机Linux系统

2、package='com.mumu.store' (com.mumu.store为应用的包名)

3、pm clear $package (清除应用的数据)

4、am force-stop $package (停止浏览器)

5、am start -S -W $package/com.mumu.store.MainActivity (启动浏览器), 返回结果如下:

Stopping: com.mumu.store
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.mumu.store/.MainActivity }
Status: ok
Activity: com.mumu.store/.MainActivity
ThisTime: 1097
TotalTime: 1097
WaitTime: 1116

使用adb logcat命令查看APP启动的时间

adb logcat | grep -i displayed

07-25 17:12:30.913   685   704 I ActivityManager: Displayed com.mumu.store/.MainActivity: +1s33ms
07-25 17:14:55.139   685   704 I ActivityManager: Displayed com.xueqiu.android/.view.WelcomeActivityAlias: +1s179ms
07-25 17:15:04.317   685   704 I ActivityManager: Displayed com.mumu.store/.MainActivity: +1s138ms
07-25 17:28:24.263   685   704 I ActivityManager: Displayed com.mumu.store/.MainActivity: +1s97ms

使用ffmpeg拆帧的方式

1、adb shell am force-stop package(包名)

2、adb shell screenrecord --bugreport --time-limit 30 /data/local/tmp/store.mp4 & (录制一个30s的MP4视频,存在手机的在指定目录下,&在Mac电脑上可以后台运行,在windows上没有用)

3、adb pull /data/local/tmp/store.mp4 C:\Users\x4023\Desktop (从手机上获取文件放到电脑指定路径下)

4、ffmpeg -i C:\Users\x4023\Desktop\store.mp4 -r 10 frames_%03d.jpg(使用任意拆帧工具,如ffmpeg,需要先下载ffmpeg,-r 10为将1s的视频拆为10帧,保存为jpg格式的图片)