標籤:
Bootchart is a system designed to show a graphical display of the activity of a system during boot.
。。。
省略官方簡介,下面是相關串連:
http://www.elinux.org/Using_Bootchart_on_Android;
http://www.bootchart.org/;
1、Installing the bootchart tool 安裝工具
sudo apt-get install bootchart
2、Building ‘init‘ with bootchart support 重新編譯init
可以重新編譯整個工程
$ cd mydroid$ export INIT_BOOTCHART=true$ make clean$ make
或者是單獨編譯init模組
$ touch system/core/init/init.c $ m INIT_BOOTCHART=true
3、Installing ‘init‘ into your system image 重新載入init模組
重新刷機或者adb push 到android機台,注意更改許可權;
adb push out/target/product/generic/root/init /init
4、Triggering bootchart functionality on system boot 使能bootchart 工具
adb shell ‘echo 120 > /data/bootchart-start‘
5、Retrieving the collected data from the system 擷取資料
在/data/bootchart檔案下bootchart 產生的資料
可以使用bootchart 內建的指令碼grab-bootchart.sh進行拷貝和打包;也可以自行進行adb pull到ubuntu機器中進行打包;
6、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
Using Bootchart on Android 在開機測量中的應用