Battery Historian之App耗电量测试

一、Battery Historian测试所需环境:Go+Git+Python+Java+Battery Historian源码

下载Battery Historian源码并且运行的步骤如下:

1.打开Git Bash 输入命令行go get -d -u github.com/google/battery-historian/...    (注意:命令后面有三个点)

2.进入到$GOPATH/src/github.com/google/battery-historian目录下方

3.运行Battery Historian,命令:go run setup.go

二、打开浏览器,访问地址
http://localhost:9999/

三、生成adb采集日志文件txt, 执行步骤
1.adb shell dumpsys batterystats --enable full-wake-history
2.adb shell dumpsys batterystats --reset
3.拔出USB
4.执行测试用例
5.adb bugreport > filename.txt
6.adb shell dumpsys batterystats --disable full-wake-history

四、将filename.txt文件上传到http://localhost:9999/ 的“Power Monitor File” 提交后会自动分析

五、关注Battery Level 曲线,在app Selection选择测试的app,在右侧查看App Stats,关注以下指标值

    --Devices estimated power use

    --Foreground

    --Services下方的相关进程

    --Process info

原文地址:https://www.cnblogs.com/luihengk/p/9004163.html