APP性能优化-Memory
APP性能优化-稳定性(crash率)
APP性能优化-包体压缩
APP性能优化-CPU
APP性能优化-UI
APP性能优化-流畅度
APP流畅度是给用户最直观的体验,用户体验下降轻则吐槽、投诉,重则直接卸载。最直观的方式体现流畅度就是在开发者选项
->GPU呈现模式
->显示条形图
APP在运行过程中如果柱状图基本都在临界线以下说明基本流畅能。部分公司在KPI考核时总需要一些数据来说明自己的APP比竞品好,好多少?需要具体的数据来支撑,总不能贴几张条形图吧...如果能获取到条形图的原始数据再做成报表上报给老板岂不美哉。
dumpsys gfxinfo
获取条形图原始数据需要将GPU呈现模式改为adb shell dumpsys gfxinfo
在
cmd
中运行 adb shell dumpsys gfxinfo < PACKAGE_NAME >
将得到以下原始数据
Total frames rendered: 203073
Janky frames: 3995 (1.97%)
50th percentile: 5ms
90th percentile: 7ms
95th percentile: 8ms
99th percentile: 21ms
Number Missed Vsync: 239
Number High input latency: 101
Number Slow UI thread: 2351
Number Slow bitmap uploads: 113
Number Slow issue draw commands: 1329
HISTOGRAM: 5ms=128270 6ms=38516 7ms=20516 8ms=5660 9ms=2053 10ms=1047 11ms=658 12ms=515 13ms=520 14ms=535 15ms=465 16ms=463 17ms=504 18ms=452 19ms=406 20ms=425 21ms=348 22ms=209 23ms=169 24ms=156 25ms=111 26ms=87 27ms=54 28ms=46 29ms=50 30ms=40 31ms=37 32ms=64 34ms=65 36ms=67 38ms=45 40ms=40 42ms=30 44ms=30 46ms=21 48ms=34 53ms=24 57ms=25 61ms=14 65ms=16 69ms=14 73ms=11 77ms=11 81ms=17 85ms=9 89ms=17 93ms=26 97ms=22 101ms=30 105ms=26 109ms=26 113ms=22 117ms=14 121ms=7 125ms=4 129ms=2 133ms=1 150ms=14 200ms=5 250ms=5 300ms=1 350ms=1 400ms=0 450ms=0 500ms=0 550ms=0 600ms=0 650ms=0 700ms=0 750ms=0 800ms=0 850ms=0 900ms=0 950ms=0 1000ms=0 1050ms=0 1100ms=0 1150ms=0 1200ms=0 1250ms=0 1300ms=0 1350ms=0 1400ms=0 1450ms=0 1500ms=0 1550ms=0 1600ms=0 1650ms=0 1700ms=0 1750ms=0 1800ms=0 1850ms=0 1900ms=0 1950ms=0 2000ms=0 2050ms=0 2100ms=0 2150ms=0 2200ms=0 2250ms=0 2300ms=0 2350ms=0 2400ms=0 2450ms=0 2500ms=0 2550ms=0 2600ms=0 2650ms=0 2700ms=0 2750ms=1 2800ms=0 2850ms=0 2900ms=0 2950ms=0 3000ms=0 3050ms=0 3100ms=0 3150ms=0 3200ms=0 3250ms=0 3300ms=0 3350ms=0 3400ms=0 3450ms=0 3500ms=0 3550ms=0 3600ms=0 3650ms=0 3700ms=0 3750ms=0 3800ms=0 3850ms=0 3900ms=0 3950ms=0 4000ms=0 4050ms=0 4100ms=0 4150ms=0 4200ms=0 4250ms=0 4300ms=0 4350ms=0 4400ms=0 4450ms=0 4500ms=0 4550ms=0 4600ms=0 4650ms=0 4700ms=0 4750ms=0 4800ms=0 4850ms=0 4900ms=0 4950ms=0
Caches:
Current memory usage / total memory usage (bytes):
TextureCache 5617568 / 49766400
Layers total 0 (numLayers = 0)
RenderBufferCache 0 / 4147200
GradientCache 24576 / 1048576
PathCache 0 / 8294400
TessellationCache 0 / 1048576
TextDropShadowCache 0 / 4147200
PatchCache 5056 / 131072
FontRenderer A8 1277663 / 1478656
A8 texture 0 1277663 / 1478656
FontRenderer RGBA 91020 / 5914624
RGBA texture 0 91020 / 5914624
FontRenderer total 1368683 / 7393280
Other:
FboCache 0 / 0
Total memory usage:
13040480 bytes, 12.44 MB
Pipeline=FrameBuilder
Profile data in ms:
Draw Prepare Process Execute
7.63 0.88 7.05 2.64
8.67 0.55 5.25 1.44
5.96 0.74 5.66 2.24
20.69 0.48 3.29 1.34
4.22 0.45 2.90 1.04
3.33 0.27 2.42 1.03
数据字段说明
- Total frames rendered: 缓存中收集的帧数
- Janky frames: 所有统计帧中耗时超过了16ms的帧数以及卡顿比例
- Number Missed Vsync: 垂直同步失败的帧
- Number High input latency: 处理input时间超时的帧数
- Number Slow UI thread: 因UI线程上的工作导致超时的帧数
- Number Slow bitmap uploads: 因bitmap的加载耗时的帧数
- Number Slow issue draw commands: 因绘制导致耗时的帧数
- HISTOGRAM: 5ms=128270 6ms=38516,
条形图原始数据
Draw、Prepare 、Process 、Execute为每帧在绘制各个阶段(如准备、构建list、绘制)的耗时,这4个值相加小于16ms表明这一帧是符合标准的。还有更具体的数据可以通过adb shell dumpsys gfxinfo < PACKAGE_NAME > framestats
获取,具体可参考:https://blog.csdn.net/cxq234843654/article/details/79914535
获取竞品对比数据
比如说我们有一款阅读APP需要和腾讯阅读做流畅度性能对比,通过以下步骤获取对比数据
1.使用google自动化框架UiAutomator
或者其他自动化测试框架编写测试用例脚本
2.运行adb shell dumpsys gfxinfo < PACKAGE_NAME > reset
,清空条形图缓存数据,确保得到的数据是当前测试页面的
3.执行测试脚本,执行结束后运行 adb shell dumpsys gfxinfo < PACKAGE_NAME >
获取原始数据,保存
4.在同等环境下将测试对象换位腾讯阅读,重复1、2、3步骤,获取竞原始数据保存
5.重复多次执行,获取均值,降低误差,出报表
以上只是粗略的实现方案,可以依葫芦画瓢对竞品CPU、电量等进行比较(https://www.cnblogs.com/ailiailan/p/6397663.html);也可以借助一些第三方开源工具来测试性能指标,如# Tencent/GT;
流畅度优化方案
流畅度是多方面综合优化的最终产物,可参考文章开头APP优化系列逐一进行优化