如何安装和使用battery-historian
来源:互联网 发布:我的世界随机性知乎 编辑:程序博客网 时间:2024/06/01 10:18
如何安装和使用battery-historian1
1st, 安装docker
安装环境:Ubuntu 14.04
$ sudo apt-get install docker.io
注意,不是sudo apt-get install docker哈
$ sudo docker -- run -p 8888:9999 gcr.io/android-battery-historian:2.1 --port 9999Unable to find image 'gcr.io/android-battery-historian:2.1' locally2.1: Pulling from gcr.io/android-battery-historian58488e45273c: Pull complete 25810b66099e: Pull complete 6571ba684f54: Pull complete 6ed49a73d8f0: Pull complete c53777cbfc31: Pull complete 801f200083c1: Pull complete 9790d6886da2: Pull complete 57f4ce395f3e: Pull complete 29200783fa94: Pull complete 384304f39faf: Pull complete eccc5106f465: Pull complete 91642318fc3e: Pull complete a76d9ce5d6cb: Pull complete 592b4bbc2727: Pull complete ac590fb09999: Pull complete 0b9679e44c58: Pull complete 198aa29ac5bc: Pull complete 2d217ec9c34a: Pull complete 0e23a5dd4f83: Pull complete 4499afe9afa5: Pull complete Digest: sha256:4b973376e09c9ebb7f269ceca3079eab084b14fe80d4f08c8921c9ea2fe2b527Status: Downloaded newer image for gcr.io/android-battery-historian:2.12017/08/05 02:17:16 Listening on port: 9999
从上面的提示信息看,
Unable to find image 'gcr.io/android-battery-historian:2.1' locally2.1: Pulling from gcr.io/android-battery-historian
也就是,在本地找不到android-battery-historian:2.1,那么会从网上自动下载.
2nd, 打开分析网页
打开:http://localhost:<port>从本例来看,我们直接在浏览器中打开:http://localhost:8888即可.页面如下:
3rd,从设备端获取待分析的Battery信息
To obtain a bug report from your development device running Android 7.0 and higher:$ adb bugreport bugreport.zipFor devices 6.0 and lower:$ adb bugreport > bugreport.txt
本例中:
$ adb bugreport bugreport.zipBugreport is in progress and it could take minutes to complete.Please be patient and do not cancel or disconnect your device until it completes.[100%] pulling bugreport.zip
然后点击Browse,然后选择生成的bugreport.zip,然后点击submit按钮,我发现部分浏览器这个按钮不显示,如果不显示,可以尝试换个浏览器,估计是插件的问题,这不重要,不再进行深入调查.
submit后的曲线图如下所示:
4th, battery historian源码
如果对Battery historian源码感兴趣,可以下载对应的源码,方法参考如下:
4.1 安装go语言
登录官网:
https://golang.org/doc/install
下载并解压安装包
tar -zxvf go1.8.3.linux-amd64.tar.gz
配置go语言到环境变量
vim ~/.bashrc
添加如下,注意,这个GOBIN就是go1.8.3.linux-amd64.tar.gz解压后的路径,我直接将其解压到/usr/local/下了
GOBIN=/usr/local/go/binexport PATH=$PATH:$GOBIN
然后让环境变量生效:
source ~/.bashrc
4.2 验证go语言安装是否ok
老办法,还是写个Hello, world!
mkdir srcvim hello.go
将下述内容添加进去
package main import "fmt"func main(){ fmt.Printf("hello, world\n")}
编译
go build
然后生成了可执行文件 hello
运行
$ ./hello hello, world
下载源码,它会将源码下载到:~/go/src/github.com/google (~/go是go语言默认的下载路径,具体的请参考Reference的网站)
$ go get -d -u github.com/google/battery-historian/...
编译,运行
$ cd $GOPATH/src/github.com/google/battery-historian# Compile Javascript files using the Closure compiler$ go run setup.go# Run Historian on your machine (make sure $PATH contains $GOBIN)$ go run cmd/battery-historian/battery-historian.go [--port <default:9999>]
区别:一个是用docker运行,一个是用go来运行,这里列出来,对比下:
1st: docker -- run -p <port>:9999 gcr.io/android-battery-historian/stable:3.0 --port 99992nd: go run cmd/battery-historian/battery-historian.go [--port <default:9999>]
结论:简单分析电池耗电情况,直接按1-3步骤就ok了.
Good luck!
References:
- https://github.com/google/battery-historian
https://golang.org/doc/install ↩
阅读全文
0 0
- 如何安装和使用battery-historian
- Battery-historian 2.0的安装与使用
- Mac 安装使用Battery Historian遇到的问题
- battery-historian工具的使用
- 如何生成 battery historian 2 分析工具
- APP性能-电量优化-安装battery historian
- battery-historian工具环境部署及使用
- [译]Batterystats和Battery Historian实践
- Android性能优化之Ubuntu安装Battery Historian分析电量
- Battery Historian工具
- Battery-Historian基本参数介绍
- 性能优化十四之电量分析工具Battery Historian使用
- 电量分析工具 Battery Historian 的配置及使用
- 电量优化之Battery Historian
- battery historian windows环境搭建
- 性能优化之电量优化2-使用Battery Historian生成电量消耗报告
- 通过battery-historian分析wakelock对CPU和电池续航能力的影响
- 初步体验Android L的battery historian
- present viewcontroller 出来的h5调用相册问题
- HDU2216 Game III
- 【Linux】如何克隆虚拟机
- 删除字符串中重复字符。
- 我的树
- 如何安装和使用battery-historian
- webshell的NTFS交换数据流文件隐藏及Python脚本查杀
- JSONCPP遍历JSON数据
- 微信公众号中高德地图显示路线
- SpringBoot15-springboot核心-Spring Boot运行原理
- cin/cout 效率问题
- mongodb在java中常见的查询(一)
- Java final修饰符
- java中的sleep()和wait()的区别