https://www.jianshu.com/p/7477e381a7ea
CUP和内存
可以用android studio中的Profile
Snip20190517_7.png
打开后点几“+”可以选择app进行测试
Snip20190517_8.png
FPS
- 点击Android设备的“设置”->"开发者选项",然后勾选“GPU呈现模式分析”
- 打开app进行操作
- 电脑终端使用
adb shell dumpsys gfxinfo < PACKAGE_NAME >
获取fps信息.
使用上面命令之前可以用adb shell dumpsys gfxinfo < PACKAGE_NAME > reset
来重置系统中的framemetrics数据
PACKAGE_NAME为:
Snip20190517_9.png
Applications Graphics Acceleration Info:
Uptime: 102809662 Realtime: 196891968
** Graphics info for pid 31148 [com.android.settings] **
Stats since: 102794621664587ns
Total frames rendered: 105
Janky frames: 2 (1.90%)
50th percentile: 5ms
90th percentile: 7ms
95th percentile: 9ms
99th percentile: 19ms
Number Missed Vsync: 0
Number High input latency: 0
Number Slow UI thread: 2
Number Slow bitmap uploads: 0
Number Slow issue draw commands: 1
HISTOGRAM: 5ms=78 6ms=16 7ms=4 8ms=1 9ms=2 10ms=0 11ms=0 12ms=0 13ms=2 14ms=0 15ms=0 16ms=0 17ms=0 18ms=0 19ms=1 20ms=0 21ms=0 22ms=0 23ms=0 24ms=0 25ms=0 26ms=0 27ms=0
...
...
这里将逐一解释以上重点信息:
Graphics info for pid 31148 [com.android.settings]: 表明当前dump的为设置界面的帧信息,pid为31148
Total frames rendered: 105 本次dump搜集了105帧的信息
Janky frames: 2 (1.90%) 105帧中有2帧的耗时超过了16ms,卡顿概率为1.9%
Number Missed Vsync: 0 垂直同步失败的帧
Number High input latency: 0 处理input时间超时的帧数
Number Slow UI thread: 2 因UI线程上的工作导致超时的帧数
Number Slow bitmap uploads: 0 因bitmap的加载耗时的帧数
Number Slow issue draw commands: 1 因绘制导致耗时的帧数
HISTOGRAM: 5ms=78 6ms=16 7ms=4 ... 直方图数据,表面耗时为0-5ms的帧数为78,耗时为5-6ms的帧数为16,同理类推。
那么以上这些数据是怎么统计得到的呢,这时候就要引入framestat了,framestat其实是每一个frame的相信信息,记录这不同阶段下的时间戳。也就是更精准的帧的时间戳信息。