Android bootchart 工具使用

Android bootchart 工具使用



1、bootchart工具简介:

        bootchart是一个用于linux启动过程性能分析的开源软件工具,在系统启动过程自动收集CPU占用率、进程等信息,并以图形方式显示分析结果,可用作指导优化系统启动过程。

2、bootchart在Android平台使用情况:

        Android系统中已有一份bootchart的c实现,位于system/core/init/bootchart.c中。bootchart对Android开机测量是通过内建在init进程中实现的,在后台执行测量。不过bootchart的测量时段是从bootchart被初始化之后到home screen出来之前,不包括bootloader和kernel的执行时间(bootchart的原理是取代init process或是内建在init process里,所以只能取得initial script的开机过程报告)。

3、bootchart在Android平台使用步骤:

       1) Ubuntu 12.04下bootchart工具安装

       2) bootchart在Android下编译

       3) bootchart在Android下的应用

       4) bootchart测量结果图形化显示


      下面依次对上述4个步骤做详细说明

      1)、Ubuntu 12.04下bootchart工具安装:

      网上很多教程说要安装下面两个工具,经个人验证最后在制作图形化显示时,出现bootchart无法正常解析android中生成的bootchart.tgz文件。

  1. sudo apt-get install bootchart  
  2. sudo apt-get install pybootchartgui   

     异常情况如下,需要下载旧版本的bootchart工具,最终问题得到解决。

     

     下载bootchart_0.9-0ubuntu6_all.deb工具,下载地址:http://download.csdn.net/detail/sckgenius/7166477

     安装方法:sudo dpkg -i  bootchart_0.9-0ubuntu6_all.ded

    2)、bootchart在Android下编译:

         1、  vi  system/core/init/bootchart.h 修改define  BOOTCHART  0 为 define  BOOTCHART  1

  1. *  
  2.  * Copyright (C) 2008 The Android Open Source Project  
  3.  *  
  4.  * Licensed under the Apache License, Version 2.0 (the "License");  
  5.  * you may not use this file except in compliance with the License.  
  6.  * You may obtain a copy of the License at  
  7.  *  
  8.  *      http://www.apache.org/licenses/LICENSE-2.0  
  9.  *  
  10.  * Unless required by applicable law or agreed to in writing, software  
  11.  * distributed under the License is distributed on an "AS IS" BASIS,  
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
  13.  * See the License for the specific language governing permissions and  
  14.  * limitations under the License.  
  15.  */  
  16.   
  17. #ifndef _BOOTCHART_H  
  18. #define _BOOTCHART_H  
  19.   
  20. #ifndef BOOTCHART  
  21. # define  BOOTCHART  0   // 修改define  BOOTCHART  1  
  22. #endif  
  23.   
  24. #if BOOTCHART  
  25.   
  26. extern int   bootchart_init(void);  
  27. extern int   bootchart_step(void);  
  28. extern void  bootchart_finish(void);  
  29.   
  30. # define BOOTCHART_POLLING_MS   200   /* polling period in ms */  
  31. # define BOOTCHART_DEFAULT_TIME_SEC    (2*60)  /* default polling time in seconds */  
  32. # define BOOTCHART_MAX_TIME_SEC        (10*60) /* max polling time in seconds */  
  33.   
  34. #endif /* BOOTCHART */  
  35.   
  36. #endif /* _BOOTCHART_H */   

       2、添加bootchart进入系统中,执行如下命令:

  1. touch system/core/init/init.c    
  2. export INIT_BOOTCHART=true   
       其中touch命令的作用就是将init.c文件的最后修改时间改为当前时间,这样保证init.c文件会被重新make,而bootchart就是在init.c中被调用的,从而保证bootchart会被编进系统中,重新编译固件编译生成新的可执行文件init,该文件在手机文件系统位于根/下,对应的flash image是boot.img,为此需重新烧写含有新的init的boot.img。
   3) bootchart在Android下的应用:

      1、将编译生成的带有bootchart工具的Android系统重新烧录到开发板上,并启动系统。

       2、在系统data目录创建文件/data/bootchart-start,其内容是bootchart的采样时间:

  1. adb shell 'echo $TIMEOUT > /data/bootchart-start'  
             其中$TIMEOUT是期望采样的时间,单位为秒,例如要采样两分钟,则执行:   
  1. adb shell 'echo 120 > /data/bootchart-start'  
        3、在系统data目录创建/data/bootchart,执行
  1. adb shell 'mkdir /data/bootchart'   
              在开发板上系统的/data/目录下新建目录bootchart/用来存放bootchart的测量结果,后面要利用这些文件生成可视化图片。

        4、重新启动开发板,在开发板的Android系统的/data/bootchart/目录下将看到以下5个文件组成:

   

         到此为止,bootchart执行测量后生成的测量数据已经完成,看上面有3个.log文件,下面进行生成美观的图形化显示。

         需要注意,在开发板上运行bootchart采样完成后若不再使用bootchart则需手工删除文件/data/bootchart-start,否则开发板每次重启时都会运行bootchart。

   4) bootchart测量结果图形化显示:

       1、生成bootchart.tgz 在data/bootchart目录执行以下命令:   

  1. busybox tar -czf bootchart.tgz *  
           或者使用android源码打包工具中提供的 grab-bootchart.sh文件进行打包,源码路径:system/core/init/grab-bootchart.sh

       2、生成美观的图形化显示

            拷贝/data/bootchart下刚才生成的 bootchart.tgz到Linux环境下,执行:        

  1. java -jar /usr/share/bootchart/bootchart.jar  /path/bootchart.tgz  
            执行上面命名会在/path目录生成一个bootchart.svgz 问题,下面对其进行重命名
  1. sudo mv bootchart.svgz bootchart.svg.gz  
            重命名完成后执行
  1. sudo gzip -d bootchart.svg.gz  
            此时会发现在path目录生成名为bootchart.svg图片,到此大功告成,美观的图形化显示show出来了。

         


转载地址:http://blog.csdn.net/andylau6789/article/details/24654385

          

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值