Android app专项测试之启动性能分析

一、前言

二、app启动性能指标分类

  1、冷启动

  Android官方建议不超过5s

  2、暖启动

   Android官方建议不超过2s

  3、热启动

   Android官方建议不超过1.5s

  4、首屏启动

三、主要测试方法

  1、adb logcat

     清理缓存数据:adb shell pm clear $Yourpackage
     停止进程:adb shell am force-stop $package
     启动app:adb shell am start -S -W $package/$YourActivity
     获取数据:adb logcat | findstr -i displayed
     结果分析,得到三个时间,如下:
     ThisTime:最后一个Activity启动耗时
     TotalTime:所有Activity启动耗时
     WaitTime:AMS启动Activity的总耗时
     这种方法测量,在线下使用方便,但是不能带到线上运行,且测量的时间不是精确时间   

  2、录屏+视频拆帧

        adb shell am force-stop com.anjounail.app
        adb shell screenrecord --bugreport --time-limit 30 /data/local/tmp/anjounail.mp4 &
        adb shell am start -S -W com.anjounail.app/.UI.Start.WelcomeActivity
        adb pull /data/local/tmp/anjounail.mp4 .
        ffmpeg -i anjounail.mp4 anjounail.gif
        ffmpeg -i anjounail.mp4 -r 10 frames_%03d.jpg  

  3、uiautomator等自动化工具200ms巡检界面变化
  4、traceview
  5、硬埋点

参考博客:
https://blog.csdn.net/asd501823206/article/details/107202670

知道、想到、做到、得到
原文地址:https://www.cnblogs.com/Durant0420/p/13431497.html