使用bootchart 对 高通Android 进行性能分析

使用bootchart 对 高通Android 进行性能分析,第1张

概述使用bootchart对高通Android进行性能分析Android版本:7.0适用平台:高通和MTK参考:https://blog.csdn.net/qq_19923217/article/details/81043736https://www.zybuluo.com/guhuizaifeiyangote/886803bootchart简介bootchart是一个用于linux启动过程性能分析的开源工 使用bootchart 对 高通AndroID 进行性能分析

AndroID版本:7.0

适用平台:高通和MTK

参考:

https://blog.csdn.net/qq_19923217/article/details/81043736https://www.zybuluo.com/guhuizaifeiyang/note/886803bootchart 简介

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

bootchart 让用户可以很直观的查看系统启动的过程和各个过程耗费的时间,以便让用户能够分析启动过程,从而进行优化以提高启动时间。

它由 bootchartd 服务和 bootchart-render 两部分组成,后者主要负责生成启动流程的分析结果图。

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

参考文档:system/core/init/readme.txt中的Bootcharting这一章

Bootcharting------------This version of init contains code to perform "bootcharting": generating logfiles that can be later processed by the tools provIDed by www.bootchart.org.On the emulator, use the -bootchart <timeout> option to boot with bootchartingactivated for <timeout> seconds.On a device, create /data/bootchart/start with a command like the following:  adb shell 'echo $TIMEOUT > /data/bootchart/start'Where the value of $TIMEOUT corresponds to the desired bootcharted period inseconds. Bootcharting will stop after that many seconds have elapsed.You can also stop the bootcharting at any moment by doing the following:  adb shell 'echo 1 > /data/bootchart/stop'Note that /data/bootchart/stop is deleted automatically by init at the end ofthe bootcharting. This is not the case with /data/bootchart/start, so don'tforget to delete it when you're done collecting data.The log files are written to /data/bootchart/. A script is provIDed toretrIEve them and create a bootchart.tgz file that can be used with thebootchart command-line utility:  sudo apt-get install pybootchartgui  # grab-bootchart.sh uses $ANDROID_SERIAL.  $ANDROID_BUILD_top/system/core/init/grab-bootchart.shOne thing to watch for is that the bootchart will show init as if it startedrunning at 0s. You'll have to look at dmesg to work out when the kernelactually started init.Comparing two bootcharts------------------------A handy script named compare-bootcharts.py can be used to compare thestart/end time of selected processes. The aforementioned grab-bootchart.shwill leave a bootchart tarball named bootchart.tgz at /tmp/androID-bootchart.If two such barballs are preserved on the host machine under differentdirectorIEs, the script can List the timestamps differences. For example:Usage: system/core/init/compare-bootcharts.py base_bootchart_dir       exp_bootchart_dirprocess: 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)
bootchart 在 androID 平台的使用步骤编译 bootchart

在 AndroID 5.1 之前 bootchart 是没有编译进系统的,需要使用下面的宏手动打开编译,在 AndroID 6.0 以上系统默认已经编译了 bootchart,

可以 adb shell 命令进入文件系统,可以看到 /data/bootchart 目录存在。

打开 bootchart 收集开机数据

0、修改高通代码:system/core/init/AndroID.mk,删掉下列这一行,重新编译烧录boot.imgsystem.img

如果没有此步骤,将导致手机不断重启,无法开机。

LOCAL_SANITIZE := integer

安卓7.1的代码。一直不断重启:system/core/init/bootchart.cpp 这个文件有BUG

stat.replace(open + 1, close - open - 1, full_name); 这个函数注释不跑就不会一直重启了,但是这样对你bootchart造成多大影响你看看,是否还能分析。

1、首先使能 bootchart,bootchart *** 作的前提是存在 enable 标记

所以 在你不需要收集数据的时候别忘了删除这个标记。

adb shell 'touch /data/bootchart/enabled'

2、抓取

adb shell 'echo $TIME_OUT > /data/bootchart/start' # 添加 bootchart timeout 时间adb shell reboot # 重启后生效

其中$TIMEOUT是期望采样的时间,单位为秒,例如要采样两分钟,则执行:

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

3、提取

可以看到 bootchart 生成的数据文件和 log 都被保存在 /data/bootchart 路径下,打包以后使用 adb pull 命令将文件拷贝出来

下列的命令也可以使用:system/core/init/grab-bootchart.sh代替

adb shell 'cd /data/bootchart ;tar -zcf boochart.tgz *'
在 HOST 机上分析 bootchart 图表PC 机安装 bootchart 工具
sudo apt-get install -y pybootchartgui
生成 bootchar 图表

拷贝 bootchart.tgz 到 PC 中,并执行下面的命令生成图表

bootchart bootchart.tgz
bootchart 图形分析小技巧

整个图表以时间线为横轴,图标上方为 cpu 和 磁盘的利用情况,下方是各进程的运行状态条,显示各个进程的开始时间与结束时间以及对 cpu、I/O 的利用情况,我们关心的各个进程的运行时间以及 cpu 的使用情况,进而优化系统。

可以通过 Laucher 的启动时间判断开机完成完成时间

通过进程的时间长短判断是否存在异常,如图表上的 第一个 Zygote 进程启动时间很短,显示存在异常,后又成功重新启动了一遍。

总结

以上是内存溢出为你收集整理的使用bootchart 对 高通Android 进行性能分析全部内容,希望文章能够帮你解决使用bootchart 对 高通Android 进行性能分析所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1039637.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存