foreword
Power Consumption Index
Standby time becomes the target of attention
Improve user experience
Through different test scenarios, find out the high power consumption scenarios of the app and solve them
01. Required environmental preparations
1. python2.7 (must be 2.7, 3.X version is not supported)
2. Golang language development environment
3. Android SDK
These three environments will not be described in detail here, and you can find information on the Internet by yourself
02. Battery-historian service construction
1. Clone the installation package
git clone https://github.com/google/battery-historian.git
2. Download the code and dependencies of battery-historian
go get -d -u github.com/google/battery-historian/…
3. Modify the value of the parameter
closureCompilerVersion = "20170409" in the setup.go file
to
closureCompilerVersion = "20190513"
because the version is different and the compilation will fail, so upgrade to the stable version
4. Switch to the directory where setup.go is located and compile
go run setup.go
5、启动battery-historian服务
go run cmd/battery-historian/battery-historian.go
6. Verify whether the installation is successful http://localhost:9999/, if the following appears, then ok
03. Collect power consumption data
1. Clean up power consumption data
adb kill-server
adb start-server
adb shell dumpsys batterystats --reset
adb shell dumpsys batterystats --enable full-wake-history
2. Run the test case/manual operation
Use monkey or appium to operate the Android application you want to test. It is best to last for a few minutes before the effect is more obvious. I will not elaborate here.
3. Collect data
The command used for Android 7.0 and above: adb bugreport bugreport.zip The command used for Android 6.0 or below: adb bugreport > bugreport.txt
04. Upload data and conduct data analysis