Android 性能测试报告工具 battery-historian试用


Github 地址: https://github.com/google/battery-historian 

Getting Started

If you are new to the Go programming language:

  • Follow the instructions available at http://golang.org/doc/install for downloading and installing the Go compilers, tools, and libraries.
  • Create a workspace directory according to the instructions athttp://golang.org/doc/code.html#Organization and ensure that GOPATH and GOBIN environment variables are appropriately set and added to your $PATH environment variable. $GOBIN should be set to $GOPATH/bin.

Next, install Go support for Protocol Buffers by running go get.

# Grab the code from the repository and install the proto package.
$ go get -u github.com/golang/protobuf/proto
$ go get -u github.com/golang/protobuf/protoc-gen-go

The compiler plugin, protoc-gen-go, will be installed in $GOBIN, which must be in your $PATH for the protocol compiler, protoc, to find it.

Next, download the Battery Historian 2.0 code:

# Download Battery Historian 2.0
$ go get -u github.com/google/battery-historian

$ cd $GOPATH/src/github.com/google/battery-historian

# Compile Javascript files using the Closure compiler
$ bash setup.sh

# Run Historian on your machine (make sure $PATH contains $GOBIN)
$ go run cmd/battery-historian/battery-historian.go [--port <default:9999>]

Remember, you must always run battery-historian from inside the $GOPATH/src/github.com/google/battery-historian directory:

cd $GOPATH/src/github.com/google/battery-historian
go run cmd/battery-historian/battery-historian.go [--port <default:9999>]
How to take a bug report

To take a bug report from your Android device, you will need to enable USB debugging under Settings > System > Developer Options. On Android 4.2 and higher, the Developer options screen is hidden by default. You can enable this by following the instructions here.

Next, to obtain a bug report from your development device

$ adb bugreport > bugreport.txt

Start analyzing!

You are all set now. Run historian and visit http://localhost:9999 and upload the bugreport.txtfile to start analyzing.

By default, Android does not record timestamps for application-specific userspace wakelock transitions even though aggregate statistics are maintained on a running basis. If you want Historian to display detailed information about each individual wakelock on the timeline, you should enable full wakelock reporting using the following command before starting your experiment:

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

Note that by enabling full wakelock reporting the battery history log overflows in a few hours. Use this option for short test runs (3-4 hrs).

To reset aggregated battery stats and timeline at the beginning of a measurement:

adb shell dumpsys batterystats --reset		

#############################

按照说明安装Go,下载代码到本地基本就ok了

有一篇试用文章,文章地址:http://m.blog.csdn.net/blog/qhshiniba/44084159

输入命令,重置设备电池状态

adb shell dumpsys batterystats --enable full-wake-history
adb shell dumpsys batterystats --reset
 
实际试用过程中发现,使用设备的过程中若连接着usb口,获取的数据都是0.
测试过程:
1、执行battery-historian
2、重置电池状态
3、设备在未充电状态下,打开爱奇艺的一个视频播放了一段时间,然后插上usb口,
输入命令:
adb bugreport > bugreport.txt
命令执行完毕后会生成bugreport.txt文件 
4、在 http://localhost:9999  中上传文件生成报告

数据很详细,可参照试用文章中的说明对照参考

参数说明

battery_level

电量,可以看出电量的变化。比如上图中的数据显示刚开始电量是100%,然后在第11秒-12秒中间的某个时刻降到了99%。

plugged

充电状态,这一栏显示是否进行了充电,以及充电的时间范围。例如上图反映了我们在第22s插入了数据线,然后一直持续了数据采集结束。

screen

屏幕是否点亮,这一点可以考虑到睡眠状态和点亮状态下电量的使用信息。

top

该栏显示当前时刻哪个app处于最上层,就是当前手机运行的app,用来判断某个app对手机电量的影响,这样也能判断出该app的耗电量信息。该栏记录了应用在某一个时刻启动,以及运行的时间,这对我们比对不同应用对性能的影响有很大的帮助。

wake_lock*

wake_lock 该属性是记录wake_lock模块的工作时间。是否有停止的时候等

running

界面的状态,主要判断是否处于idle的状态。用来判断无操作状态下电量的消耗。

wake_lock_in

wake_lock有不同的组件,这个地方记录在某一个时刻,有哪些部件开始工作,以及工作的时间。

data_conn

数据连接方式的改变,上面的edge是说明采用的gprs的方式连接网络的。此数据可以看出手机是使用2g,3g,4g还是wifi进行数据交换的。这一栏可以看出不同的连接方式对电量使用的影响。

status

电池状态信息,有充电,放电,未充电,已充满,未知等不同状态。  这一栏记录了电池状态的改变信息。

phone_signal_strength

手机信号状态的改变。  这一栏记录手机信号的强弱变化图,依次来判断手机信号对电量的影响。

health

电池健康状态的信息,这个信息一定程度上反映了这块电池使用了多长时间。  这一栏记录电池状态在何时发生改变,上面的图中电池状态一直处于good状态。

plug

充电方式,usb或者插座,以及显示连接的时间。  这一栏显示了不同的充电方式对电量使用的影响。

还可以查看指定app的数据

看起来挺高大上的,还需要在实际工作中使用检验是否有效 ^_^


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值