之前分析各个部分耗时,都是通过分析log,在SecureCRT中设置时间戳,打印出如下log
[ 22.266201] c1 [saudio] saudio_wait_monitor_cmd error -5
[ 22.266205] c1 sblock_receive:sblock-5-13 not ready!
[ 22.266209] c1 [saudio] Error: sblock_receive dst 5, channel 13 result is -5
[ 22.266226] c1 [saudio] saudio_wait_monitor_cmd error -5
[ 22.266229] c1 sblock_receive:sblock-5-17 not ready!
[ 22.266232] c1 [saudio] Error: sblock_receive dst 5, channel 17 result is -5
[ 22.302337] c3 init: Parsing file /system/etc/init/ims_bridged.rc...
[ 22.309790] c3 init: Parsing file /system/etc/init/init-debug.rc...
[ 22.316932] c3 init: Parsing file /system/etc/init/installd.rc...
---------------------
有效,但数据不全面,不利于分析。百度到了bootchart这个工具,很实用。
1) bootchart工具
在Android O当中,bootchart已经默认集成在Init当中。所以收集数据可以用以下步骤:
只需要你通过开关打开即可生效:“adb shell ‘touch /data/bootchart/enabled’”
重启设备
$ANDROID_BUILD_TOP/system/core/init/grab-bootchart.sh抓取数据生成一张png图片,即可进行分析。
sp8541e_srvm:/data/bootchart $ tar -czf bootchart.tgz enabled header proc_diskstats.log proc_ps.log proc_stat.log
adb pull /data/bootchart/bootchart.tgz .\Desktop\
拷贝bootchart.tgz 到Ubuntu服务器上
Ubuntu服务器上 sudo apt-get install bootchart
bootchart bootchart.tgz
命令结束后就生成对应的png图片。
但是如果碰到bootchart工具不能使用的情况,就需要自己下载bootchart源码:http://www.bootchart.org/download.html,解压后:
1. ant编译
2. java -jar bootchart.jar ../bootchart/bootchart.tgz 生成分析结果图