Battery Historian 2.0 for windows环境搭建

来源:互联网 发布:fdd网络 编辑:程序博客网 时间:2024/06/05 20:12

简介

Battery Historian 1.0 通过python脚本转换成html文件,命令如下:

python historian.py -a bugreport.txt > battery.html

在Google I/O 15 中 Battery Historian 新版本 Battery Historian 2.0 发布了,新版本带来了很多的改进:更清晰的报告,每个应用程序的摘要,更快的执行等等。虽然新功能真的很棒,但是Battery Historian的安装变得更加的复杂了,因为它增加了很多的依赖,并且它所有的文档跟脚本都是用于Linux及Mac OS上的。所以特别写了这篇Battery Historian 2.0 在windows环境下的搭建。

步骤


  1. 安装依赖项

    • Git
    • python 主要是为了1.0版本的查看
    • Go Battery Historian 2.0使用了Go语言进行了重写。所以你首先需要下载并安装它。Go 下载 并且创建一个Go的工作空间 如:mkdir E:\GoProject
  2. 安装Battery Historian 2.0

    • 打开cmd,配置Go的环境变量,并进入Go工作空间

      set GOPATH=E\\go-workspaceset GOBIN=D:\\Go\\binset PATH=%PATH%;%GOBIN%cd %GOPATH%
    • 获取go的一些依赖如:proto,protoc-gen-go 以及 Battery Historian,命令如下

      go get -u github.com/golang/protobuf/protogo get -u github.com/golang/protobuf/protoc-gen-gogo get -u github.com/google/battery-historian
    • 进入 %GOPATH%\src\github.com\google\battery-historian 新建两个目录:third_party 以及compiled. 下载 Closure compiler 并解压到 third_party\closure-compiler。结果如下:

      这里写图片描述

    • Clone closure library 到 third_party\closure-library目录下
      git clone https://github.com/google/closure-library third_party/closure-library

    • 下来我们还需要修改 battery-historian\analyzer\analyzer.go 内的代码

      -       cmd := exec.Command("./historian.py", "-c", "-m", "-r", reportName, filepath)+       cmd := exec.Command("C:\\Python27\\python.exe", "./historian.py", "-c", "-m", "-r", reportName, filepath)
    • 最后我们需要在battery-historian 执行两句命令来完成Battery Historian 2.0 的安装

      third_party\closure-library\closure\bin\build\depswriter.py --root="third_party\closure-library\closure\goog" --root_with_prefix="js ../../../../js" > compiled\historian_deps-runfiles.jsjava -jar third_party\closure-compiler\compiler.jar --closure_entry_point historian.Historian --js js\*.js --js third_party\closure-library\closure\goog\base.js --js third_party\closure-library\closure\goog\** --only_closure_dependencies --generate_exports --js_output_file compiled\historian-optimized.js --compilation_level SIMPLE_OPTIMIZATIONS

      PS:如下执行上面代码时候出现错误可查看Setup broken #42 删除目录下的html文件即可以解决问题了。

  3. 运行Battery Historian 2.0
    现在已经完成了整个安装步骤了,通过下面的命令即可运行Battery Historian了。

    set GOPATH=E:\\GoProjectcd %GOPATH%\src\github.com\google\battery-historian\E:go run cmd\battery-historian\battery-historian.gopause

    可以将上面的命令作为批处理保存,运行结果如下:
    这里写图片描述

  4. 访问 http://localhost:9999 你就能看到你的 Battery Historian 2.0 本地运行的情况了:
    这里写图片描述

  5. 好我们看看运行的报告结果吧。
    这里写图片描述

参考文档

Getting Battery Historian 2.0 to work on Windows

1 0
原创粉丝点击