Android UX性能测试
2017-05-23
目标就是找到一种简单的量化测试方法
apk启动时间测量
方法一:利用am start
一般看TotalTime,多取几次算平均。
| // adb shell am start -w packagename/MainActivityxxx:/ # am start -W com.android.settings/com.android.settings.Settings
 Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.android.settings/.Settings }
 Status: ok
 Activity: com.android.settings/.Settings
 ThisTime: 154
 TotalTime: 154
 WaitTime: 164
 
 | 
方法二:利用自带screenrecord录屏功能
- CMD窗口运行如下命令:
| xxxx:/sdcard # screenrecord  --bugreport launch.mp4
 | 
- 点击APP启动(冷启or热启)完成后ctrl-c取消录制
- 导出视频到PC上,用带按帧播放功能的player播放,一般用QuickTime专业版。
- QuickTime打开mp4
- 用键盘右键按帧找到APP icon高亮开始,如下图
- 同样方法接着找到整个APP UI的第一帧
- 计算启动耗时
方法一:dumpsys SurfaceFlinger
- 打开要测试的APP运行下面命令查看可用window name (比如photo)
| xxx:/ # dumpsys SurfaceFlinger --listcom.android.systemui.ImageWallpaper
 animation background stackId=1
 com.google.android.apps.photos/com.google.android.apps.photos.home.HomeActivity
 DimLayerController/Stack=0
 StatusBar
 
 | 
- 清空之前的历史记录
| xxx:/ # dumpsys SurfaceFlinger ----latency-clear
 | 
- 在phono界面滑动多次后运行下面命令获取127帧数据
| xxx:/ # dumpsys SurfaceFlinger --latency        com.google.android.apps.photos/com.google.android.apps.photos.home.HomeActivity16666666
 0       0       0
 . ...
 ...
 
 | 
- 计算FPS
| time = (最后一行,第二列) - (第一行,第二列) //unit:nsfps = 126000000000/time
 
 | 
- 清空循环多次,计算平均值。
方法二:dumpsys gfxinfo
- Setting->Developer options->Profile GPU rendering下选择dumpsys gfxinfo 
- 回到APP界面先运行多次下面命令,确保Profile data in ms为空
| dumpsys gfxinfo com.google.android.apps.photos...
 Profile data in ms:
 com.google.android.apps.photos/com
 Draw    Prepare Process Execute
 View hierarchy:
 
 | 
- 在APP界面滑动多次后再次运行上面命令获取simple frame timing数据
| Draw    Prepare Process Execute4.06    0.23    0.83    2.02
 1.60    0.22    0.93    1.99
 1.39    0.18    0.80    2.08
 1.41    0.19    0.84    2.06
 1.45    0.35    0.90    1.79
 1.46    0.34    0.89    1.67
 5.81    0.23    0.77    1.91
 1.25    0.18    0.95    1.46
 1.34    0.19    0.96    1.63
 1.41    0.23    0.74    1.63
 1.25    0.15    0.67    1.27
 1.21    0.15    0.67    1.28
 1.24    0.16    0.73    1.29
 1.23    0.15    0.69    1.28
 1.19    0.15    0.65    1.29
 1.02    0.16    0.72    1.31
 
 | 
拷贝到excel表格里看效果图
最直接应该就是打到屏幕上看。 
参考文档
版权声明:本站所有文章均采用 CC BY-NC-SA 4.0 CN 许可协议。转载请注明原文链接!