[原创]Android App耗电量测试总结提炼
[原创]Android App耗电量测试总结提炼
1、battery-historian工具介绍
battery-historian是一款通过上传bugreport文件分析用户手机中app的电池耗电情况的工具,它可以完成电量使用情况,生成清晰的耗电量报告
如: http://10.242.42.12:9999/
2、battery-historian安装(略)
直接采用docker安装,方便简单
请参考: https://github.com/google/battery-historian
3、Android App 耗电量测试步骤:
1、首先,电脑用数据线连接手机设备,开启设备的开发者模式后,使用adb devices命令,能够看到设备在线
2、默认情况下,android系统不会 记录特定应用的wakelock变化,为了依照时间顺序,展示各个 wakelock的详细信息,需要先执行命令:
清理耗电量数据:
adb shell dumpsys batterystats --reset
adb shell dumpsys batterystats --enable full-wake-history
3、接下来可以拔掉数据线,在手机上对被测试app执行相应的用例进入测试场景,比如:打开某App,然后置于后台2小时;
4、导出数据,手机连接电脑,执行命令:
adb shell dumpsys batterystats >mayingbao20180101.txt
6、打开Battery Historian平台将bugreport.txt导入, 并点击submit进行分析
注意事项,防坑指南:
Android 7.0及以上:adb bugreport bugreport.zip
Android 6.0及以下: adb bugreport > bugreport.txt