zoukankan      html  css  js  c++  java
  • Android——bootchart

    bootchart:android原生自带的开机性能查看机制。通过收集android开机过程中的各种log数据,终于能够图表的形式展现各个进程在开机过程中的性能。(博客不能断…)

    撰写不易,转载需注明出处:http://blog.csdn.net/jscese/article/details/45933943本文来自 【jscese】的博客。

    编译bootchart

    bootchart 源代码位于:systemcoreinitootchart.c 属于init
    查看相应Android.mk,当中有这么一段:

    ifeq ($(strip $(INIT_BOOTCHART)),true)
    LOCAL_SRC_FILES += bootchart.c
    LOCAL_CFLAGS    += -DBOOTCHART=1
    endif

    非常明显的变量控制编译了,假设想要把bootchart编译进init。要么就export 这个变量为true,要么就定义赋值。
    还有个相应的bootchart.h 头文件。里面有宏控制,想要用bootchart,怎么改就不多说了~

    原生的启动是放在init.c的main里面:

    #if BOOTCHART
    queue_builtin_action(bootchart_init_action, "bootchart_init");
    #endif

    能够看到首先跑的应该是bootchart里面的 bootchart_init 这个函数
    能够略微看下bootchart的源代码,当中有这么一句:

     proc_read( LOG_STARTFILE, buff, sizeof(buff) );
     ...
     int  fd = open( LOG_ACCT, O_WRONLY|O_CREAT|O_TRUNC,0644);
     //这些文件都是/data分区以下的

    第一个proc_read读取的算是一个配置时间: /data/bootchart-start,来决定bootchart从开启到结束的时间。
    第二个自然就是抓取的log信息 存放的位置了:/data/bootchart
    那么必定是须要data分区先挂载好,所以启动bootchart的地方得衡量!


    使用bootchart

    正常编译进系统之后,就须要手动的去设置一下上面说到的配置了:

    echo 50 > /data/bootchart-start
    //写个50s进去

    重新启动就可以。执行正常的话,可在/data/bootchart以下看到五个文件:

    root@86v:/ # ll /data/bootchart                                                
    -rw-rw-rw- root     root          517 2015-05-23 15:17 header
    -rw-r--r-- root     root            0 2015-05-23 15:17 kernel_pacct
    -rwxr-xr-x root     root       196608 2015-05-23 15:17 proc_diskstats.log
    -rwxr-xr-x root     root      3735552 2015-05-23 15:17 proc_ps.log
    -rwxr-xr-x root     root       131072 2015-05-23 15:17 proc_stat.log

    打包为bootchart.tgz:

    busybox tar zcvf bootchart.tgz header kernel_pacct proc_diskstats.log proc_ps.log proc_stat.log

    adb pull 或者直接copy出来。放到pc上。

    ubuntu的话能够用apt-get 去安装bootchart。能够用bootchart bootchart.tgz 去解析为图表。有可能会有错误。网上有人给出来了改动相应python脚本的方法,不难。
    可惜我已经不在ubuntu下了,诸多不便 - -

    Windows下的话,得去找个bootchart相应的jar包,能够从ubuntu上bootchart安装文件夹下拷出来

    java -jar bootchart.jar bootchart.tgz

    没有错误的话能够得到一张bootchart.png图片,上一张图:
    bootchart

    通俗的理解就是 蓝色为cpu占用 ,粉色为io等待,也就是文件操作的耗时,横轴为起机时间,以进程为单位描写叙述。

    就到这里吧~

  • 相关阅读:
    为图片指定区域添加链接
    数值取值范围问题
    【leetcode】柱状图中最大的矩形(第二遍)
    【leetcode 33】搜索旋转排序数组(第二遍)
    【Educational Codeforces Round 81 (Rated for Div. 2) C】Obtain The String
    【Educational Codeforces Round 81 (Rated for Div. 2) B】Infinite Prefixes
    【Educational Codeforces Round 81 (Rated for Div. 2) A】Display The Number
    【Codeforces 716B】Complete the Word
    一个简陋的留言板
    HTML,CSS,JavaScript,AJAX,JSP,Servlet,JDBC,Structs,Spring,Hibernate,Xml等概念
  • 原文地址:https://www.cnblogs.com/mthoutai/p/7040366.html
Copyright © 2011-2022 走看看