Android Bootchart使用经验

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

bootchart是一个对linux启动流程进行分析得开源软件工具。

Android Bootchart

Android 系统源码中有 bootchart 的实现,路径在 system/core/init/bootchart.cpp 中, bootchart 通过内嵌在 init 进程中实现,在后台执行测量。不过 bootchart 的测量时段是 init 进程启动之后,不包含 uboot 和 kernel 的启动时间。

在 android 源码路径 system/core/init/README.md 中包含了对 bootchart 的使用说明。

On the emulator, use the -bootchart _timeout_ option to boot with bootcharting
activated for _timeout_ seconds.

On a device:

    adb shell 'touch /data/bootchart/enabled'

Don't forget to delete this file when you're done collecting data!

The log files are written to /data/bootchart/. A script is provided to
retrieve them and create a bootchart.tgz file that can be used with the
bootchart command-line utility:

    sudo apt-get install pybootchartgui
    # grab-bootchart.sh uses $ANDROID_SERIAL.
    $ANDROID_BUILD_TOP/system/core/init/grab-bootchart.sh

One thing to watch for is that the bootchart will show init as if it started
running at 0s. You'll have to look at dmesg to work out when the kernel
actually started init.


Comparing two bootcharts
------------------------
A handy script named compare-bootcharts.py can be used to compare the
start/end time of selected processes. The aforementioned grab-bootchart.sh
will leave a bootchart tarball named bootchart.tgz at /tmp/android-bootchart.
If two such barballs are preserved on the host machine under different
directories, the script can list the timestamps differences. For example:

Usage: system/core/init/compare-bootcharts.py _base-bootchart-dir_ _exp-bootchart-dir_

    process: baseline experiment (delta) - Unit is ms (a jiffy is 10 ms on the system)
    ------------------------------------
    /init: 50 40 (-10)
    /system/bin/surfaceflinger: 4320 4470 (+150)
    /system/bin/bootanimation: 6980 6990 (+10)
    zygote64: 10410 10640 (+230)
    zygote: 10410 10640 (+230)
    system_server: 15350 15150 (-200)
    bootanimation ends at: 33790 31230 (-2560)

在 Android 5.1 之前 bootchart 是没有编译进系统的,需要使用下面的宏手动打开编译,在 Android 6.0 以上系统默认已经编译了 bootchart,可以 adb shell 命令进入文件系统,可以看到 data 下面已经有 bootchart 的目录了。

Android Bootchart使用

1.adb shell 'touch /data/bootchart/enabled'

    在/data/bootchart文件下添加enable标记,但是在不需要数据的时候要删除这个标记

2.修改完后再重新启动安卓系统发现/data/bootchart目录下有了下面几个文件:

header

proc_diskstats.log

proc_ps.log

proc_stat.log

3.adb pull /data/bootchart . 把bootchart文件夹pull到本地

4.cd bootchart ,然后执行tar -zcf bootchart.tgz *

5.生成bootchart图片 bootchart bootchart.tgz

安装bootchart工具

sudo apt-get install bootchart
sudo apt-get install pybootchartgui 

参考博文:

性能分析工具 — bootchart 工具使用(android 8.1)【转】_mb5fcdf2ea5f3c5的技术博客_51CTO博客

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值