Android app专项测试之耗电量测试

前言

耗电量指标

待机时间成关注目标

提升用户体验

通过不同的测试场景,找出app高耗电的场景并解决

01、需要的环境准备

1、python2.7(必须是2.7,3.X版本是不支持的)

2、golang语言的开发环境

3、Android SDK

此三个的环境搭建这里就不详细说了,自行在网上找资料吧

02、battery-historian服务搭建

1、克隆安装包

git clone https://github.com/google/battery-historian.git

2、下载battery-historian的代码和依赖

go get -d -u github.com/google/battery-historian/...

3、修改setup.go文件的参数

closureCompilerVersion = "20170409"

值修改为

closureCompilerVersion = "20190513"

因为版本不一样,编译会失败,所以升级到稳定版本

4、切换到setup.go所在的目录,进行编译

go run setup.go

5、启动battery-historian服务

go run cmd/battery-historian/battery-historian.go

6、验证是否安装成功http://localhost:9999/,出现如下,则ok![在这里插入图片描述](https://file.jishuzhan.net/article/1691392710746836994/536275e9fdb7496eb0687e720f1a685d.jpeg)

03、进行耗电量数据收集

1、清理耗电量数据

adb kill-server

adb start-server

adb shell dumpsys batterystats --reset

adb shell dumpsys batterystats --enable full-wake-history

2、运行测试用例/手工操作

使用monkey或appium来操作想要被测试的Android应用,最好就持续几个钟,效果才比较明显,这里具体就不展开详细说明了

3、收集数据

Android 7.0以上版本使用的命令 :adb bugreport bugreport.zipAndroid 6.0 或以下使用的命令:adb bugreport > bugreport.txt

04、上传数据,进行数据分析

相关推荐
Storm-Shadow19 小时前
Android OpenGLES视频剪辑示例源码
android·opengles·视频滤镜
双桥wow19 小时前
android 堆栈打印
android
爱学习的大牛1231 天前
使用C++开发Android .so库的优势与实践指南
android·.so·1024程序员节
帅锅锅0071 天前
SeLinux Type(类型)深度解析
android·操作系统
2501_915921431 天前
iOS混淆与IPA加固全流程(iOS混淆 IPA加固 Ipa Guard实战)
android·ios·小程序·https·uni-app·iphone·webview
游戏开发爱好者81 天前
iOS 26 App 开发阶段性能优化 从多工具协作到数据驱动的实战体系
android·ios·小程序·uni-app·iphone·webview·1024程序员节
2501_915106321 天前
深入剖析 iOS 26 系统流畅度,多工具协同监控与性能优化实践
android·ios·性能优化·小程序·uni-app·cocoa·iphone
小彤花园1 天前
GooglePlay更改签名秘钥报错(2025最新版)
android·google
Answer_momo1 天前
一文读懂 Kotlin 数据流 Flow 的使用
android