Using Bootchart on Android 在開機測量中的應用

Bootchart is a system designed to show a graphical display of the activity of a system during boot.python

。。。linux

省略官方簡介,下面是相關鏈接:android

http://www.elinux.org/Using_Bootchart_on_Android; shell

http://www.bootchart.org/; ubuntu

一、Installing the bootchart tool 安裝工具
工具

sudo apt-get install bootchart

二、Building 'init' with bootchart support 從新編譯initui

    能夠從新編譯整個工程    spa

$ cd mydroid
$ export INIT_BOOTCHART=true
$ make clean
$ make

    或者是單獨編譯init模塊
.net

 $ touch system/core/init/init.c
 $ m INIT_BOOTCHART=true

三、Installing 'init' into your system image 從新加載init模塊code

    從新刷機或者adb push 到android機臺,注意更改權限;

adb push out/target/product/generic/root/init /init

四、Triggering bootchart functionality on system boot 使能bootchart 工具

adb shell 'echo 120 > /data/bootchart-start'

五、Retrieving the collected data from the system 獲取數據

    在/data/bootchart文件下bootchart 生成的數據

    能夠使用bootchart 自帶的腳本grab-bootchart.sh進行拷貝和打包;也能夠自行進行adb pull到ubuntu機器中進行打包;

六、Generating the graphic from the data 生成png圖片

$bootchart ./bootchart.tgz

執行該命令後,直接生成錯誤提示:

    parsing 'header'  
    parsing 'proc_stat.log'  
    parsing 'proc_ps.log'  
    warning: no parent for pid '2' with ppid '0'  
    parsing 'proc_diskstats.log'  
    parsing 'kernel_pacct'  
    merged 0 logger processes  
    pruned 63 process, 0 exploders, 2 threads, and 0 runs  
    False  
    Traceback (most recent call last):  
      File "/usr/bin/bootchart", line 23, in <module>  
        sys.exit(main())  
      File "/usr/lib/pymodules/python2.6/pybootchartgui/main.py", line  
    137, in main  
        render()  
      File "/usr/lib/pymodules/python2.6/pybootchartgui/main.py", line  
    128, in render  
        batch.render(writer, res, options, filename)  
      File "/usr/lib/pymodules/python2.6/pybootchartgui/batch.py", line  
    41, in render  
        draw.render(ctx, options, *res)  
      File "/usr/lib/pymodules/python2.6/pybootchartgui/draw.py", line  
    282, in render  
        draw_chart(ctx, IO_COLOR, True, chart_rect, [(sample.time,  
    sample.util) for sample in disk_stats], proc_tree)  
      File "/usr/lib/pymodules/python2.6/pybootchartgui/draw.py", line  
    201, in draw_chart  
        yscale = float(chart_bounds[3]) / max(y for (x,y) in data)  
    ZeroDivisionError: float division

該錯誤是由python版本致使,進行如下修改能夠解決該問題:修改下/usr/share/pyshared/pybootchartgui/目錄的draw.py,parsing.py,samples.py三個文件:

draw.py

    將200,201行由:  
    xscale = float(chart_bounds[2]) / max(x for (x,y) in data)  
    yscale = float(chart_bounds[3]) / max(y for (x,y) in data)  
    改成:  
    xscale = float(chart_bounds[2]) / max(0.00001, max(x for (x,y) in data))  
    yscale = float(chart_bounds[3]) / max(0.00001, max(y for (x,y) in data))

parsing.py

在156行後添加:  
    if interval == 0:  
        interval = 1
修改後以下:  
    sums = [ a - b for a, b in zip(sample1.diskdata, sample2.diskdata) ] 
    if interval == 0:
        interval = 1

samples.py

在81行後添加:  
    if interval == 0:  
        interval = 1
修改後以下:
    def calc_load(self, userCpu, sysCpu, interval):
        if interval == 0: <br>  
            interval = 1

再次執行,即可以順利生成bootchart.png文件

$bootchart ./bootchart.tgz

生成的png文件以下所示:


參考文章:

http://blog.csdn.net/harry_helei/article/details/8545032

相關文章
相關標籤/搜索