安卓开机启动性能优化之-bootchart相关工具使用及查看

背景:

开机启动相关的详细信息,一般都是可以通过logcat中查看boot_progress相关查看,这种方式查看相对不那么方便,毕竟开机过程中涉及的进程较多,要查看也较多,而且还经常需要查看代码才可以对应起来,但有另一种方式可以通过看bootchart方式更加直观

ubuntu上相关方法

步骤1:

adb shell touch /data/bootchart/enabled

然后重启设备
重启后就会在对应的data/bootchart目录有如下文件
在这里插入图片描述这些日志文件其实就是bootchart绘制图片的基础,下面这些步骤其实就是对这log转换成图表。

步骤2:

安装相关的bootchart的库

test@test:~/demos$ git clone https://gitee.com/wasdzy/bootchart
Cloning into 'bootchart'...
remote: Enumerating objects: 2614, done.
remote: Counting objects: 100% (2614/2614), done.
remote: Compressing objects: 100% (956/956), done.
Receiving objects:  43% (1125/2614), 868.00 KiB | 561.00 KiB/s
remote: Total 2614 (delta 1620), reused 2614 (delta 1620), pack-reused 0
Receiving objects: 100% (2614/2614), 1.85 MiB | 767.00 KiB/s, done.
Resolving deltas: 100% (1620/1620), done.

再进行编译

test@test:~/demos$ cd bootchart/
test@test:~/demos/bootchart$ make

可以看到已经编译出来了pybootchartgui.py文件
在这里插入图片描述
再进行安装

test@test:~/demos/bootchart$ sudo make install
[sudo] password for test: 
install -d /usr/lib/python3.8/site-packages/pybootchartgui
cp pybootchartgui/*.py /usr/lib/python3.8/site-packages/pybootchartgui
install -D -m 755 pybootchartgui.py /usr/bin/pybootchartgui
[ -z "" ] && ( cd /usr/lib/python3.8/site-packages/pybootchartgui ; \python3 /usr/lib/python3.8/py_compile.py *.py ; \PYTHONOPTIMIZE=1 python3 /usr/lib/python3.8/py_compile.py *.py ); :
install -d /lib/bootchart/tmpfs
install -m 755 -D bootchartd /sbin/bootchartd
install -m 644 -D bootchartd.conf /etc/bootchartd.conf
install -m 755 -D bootchart-collector /lib/bootchart/bootchart-collector
mkdir -p /lib/systemd/system
install -m 0644 bootchart2.service \bootchart2-done.service \bootchart2-done.timer \/lib/systemd/system
install -m 644 -D README /usr/share/docs/bootchart/README
install -m 644 -D README.pybootchart /usr/share/docs/bootchart/README.pybootchart
mkdir -p /usr/share/man/man1
gzip -c bootchart2.1 > /usr/share/man/man1/bootchart2.1.gz
gzip -c bootchartd.1 > /usr/share/man/man1/bootchartd.1.gz
gzip -c pybootchartgui.1 > /usr/share/man/man1/pybootchartgui.1.gz

步骤3:

执行aosp自带的grab-bootchart.sh

test@test:~/disk2/aosp14$ ./system/core/init/grab-bootchart.sh 
adb server version (41) doesn't match this client (39); killing...* daemon started successfully
Traceback (most recent call last):File "/usr/bin/pybootchartgui", line 20, in <module>from pybootchartgui.main import main
ModuleNotFoundError: No module named 'pybootchartgui'
gio: file:///home/test/disk2/aosp14/bootchart.png: Error when getting information for file “/home/test/disk2/aosp14/bootchart.png”: No such file or directory
Clean up /tmp/android-bootchart/ and ./bootchart.png when done

发现还是会传递报错找不到,干脆直接依赖编译出来的
手动修改init/grab-bootchart.sh文件

diff --git a/init/grab-bootchart.sh b/init/grab-bootchart.sh
index 2c56698a1..37c5a4eeb 100755
--- a/init/grab-bootchart.sh
+++ b/init/grab-bootchart.sh
@@ -17,6 +17,7 @@ for f in $FILES; doadb "${@}" pull $LOGROOT/$f $TMPDIR/$f 2>&1 > /dev/nulldone(cd $TMPDIR && tar -czf $TARBALL $FILES)
-pybootchartgui ${TMPDIR}/${TARBALL}
+#pybootchartgui ${TMPDIR}/${TARBALL}
+~/demos/bootchart/pybootchartgui.py ${TMPDIR}/${TARBALL}xdg-open ${TARBALL%.tgz}.pngecho "Clean up ${TMPDIR}/ and ./${TARBALL%.tgz}.png when done"

最重要就是把pybootchartgui直接变成~/demos/bootchart/pybootchartgui.py
再执行

test@test:~/disk2/aosp14$ ./system/core/init/grab-bootchart.sh
parsing '/tmp/android-bootchart/bootchart.tgz'
parsing 'header'
parsing 'proc_stat.log'
parsing 'proc_ps.log'
parsing 'proc_diskstats.log'
merged 0 logger processes
pruned 66 process, 0 exploders, 17 threads, and 0 runs
bootchart written to 'bootchart.png'
Clean up /tmp/android-bootchart/ and ./bootchart.png when done

注意如果有的机器有ImportError: No module named cairo报错,则需要sudo apt-get install python-cairo
执行后自动就打开了表格图:
在这里插入图片描述

windows上相关方法

上面是对于ubuntu系统上,也可以windows上使用,因为上面说过本质其实就是data/bootchart下面日志进行解析生成png
这里可以把日志打包,然后bootchart解析。
adb shell进入设备对日志进行打包:

emulator_x86_64:/data/bootchart #  tar -czvf bcl.tar.gz *log
proc_diskstats.log
proc_ps.log
proc_stat.log

打包好成了 bcl.tar.gz文件,再进行导出用bootchart.jar进行解析生成图片
bootchart.jar下载地址:
https://share.weiyun.com/NdM2ZE4F

接下来在导出日志进行解析

test@test:~/Downloads$ adb pull /data/bootchart/bcl.tar.gz .
test@test:~/Downloads$ java -jar bootchart.jar bcl.tar.gz 
Parsing bcl.tar.gz
Wrote image: ./bcl.png

在这里插入图片描述

bootchart前后对比法:

上面通过图形绘制绘制出开机启动的时间后,可以通过图形大概看出时间点,但是明显图形时间坐标不够精确,那么优化前后有没有什么方法可以可以精确对比出两次优化时间呢?这个android其实也是有自带相关的工具

具体可以参考如下py文件:
system/core/init/compare-bootcharts.py

具体原理可以看这个脚本,就是对比相关主要进程的log的time

在这里插入图片描述

具体的使用对比方式:
log文件打包成bootchart.tgz
在这里插入图片描述
在这里插入图片描述
然后使用如下命令:

test@test:~/Downloads$ ~/disk2/aosp14/system/core/init/compare-bootcharts.py bcl1 bcl
process: baseline experiment (delta)- Unit is ms (a jiffy is 9 ms on the system)
------------------------------------
/system/bin/surfaceflinger: 6561 5628 (-933)
/system/bin/bootanimation: 7104 6104 (-1000)
zygote64: 6361 5438 (-923)
zygote: 6361 5447 (-914)
system_server: 17428 15723 (-1704)
bootanimation ends at: 31809 30142 (-1666)

上面就有对比出相关surfaceflinger,bootanimation,system_server时间等

具体详情试看方式:
投屏专题部分:
https://mp.weixin.qq.com/s/IGm6VHMiAOPejC_H3N_SNg

更多framework详细代码和资料参考如下链接

hal+perfetto+surfaceflinger
https://mp.weixin.qq.com/s/LbVLnu1udqExHVKxd74ILg
在这里插入图片描述

其他课程七件套专题:在这里插入图片描述
点击这里
https://mp.weixin.qq.com/s/Qv8zjgQ0CkalKmvi8tMGaw

视频试看:
https://www.bilibili.com/video/BV1wc41117L4/

参考相关链接:
https://blog.csdn.net/zhimokf/article/details/137958615

更多framework假威风耗:androidframework007

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/50381.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

前端系列-8 集中式状态管理工具pinia

集中式状态管理工具—pinia vue3中使用pinia作为集中式状态管理工具&#xff0c;替代vue2中的vuex。 pinia文档可参考: https://pinia.web3doc.top/introduction.html 1.项目集成pinia 安装pinia依赖: npm install pinia在main.ts中引入pinia import { createApp } from vu…

Facebook和Instagram运营中的注意事项和QA

Facebook注意事项 1.Facebook的几种违规行为&#xff1a;加好友过快或者过多&#xff1b;加群过快或者过多&#xff1b;转 发信息到群过快或者过多&#xff1b;创建主页过快或者过多&#xff1b;创建群过快或者过多&#xff1b; 主动给人发信息过多&#xff1b;IP、浏览器更换&…

spring框架实现滑动验证码功能

spring框架实现滑动验证码功能 1. 整体描述2. 具体实现2.1 滑动验证码实体类2.2 滑动验证码登录VO2.3 滑动验证码接口返回类2.4 滑动验证码工具类2.5 滑动验证码Service2.6 滑动验证码Controller 3 工程源码4 总结 1. 整体描述 之前项目需要在验证码模块&#xff0c;增加滑动验…

Android中接入hook框架:lancet-base

me.ele:lancet-base是"饿了么"开发的Android平台的开源hook框架&#xff0c;GitHub地址为&#xff1a;https://github.com/eleme/lancet。 此框架的优点如下&#xff1a; 1.编译速度快, 并且支持增量编译。 2.简洁的 API, 几行 Java 代码完成注入需求。 3.没有任何多…

Dataview的初次学习

一个很简单的例子 list from "" where contains(file.name,"教程")详细介绍 目的不是花哨&#xff0c;而是精简的整合自己的笔记&#xff0c;方便查找和翻阅。 代码块开头都省略了dataview提示词 我参考的教程&#xff1a; obsidian插件之dataview入门…

MongoDB教程 :MongoDB全文检索

MongoDB Full-Text Search Tutorial MongoDB provides a robust full-text search functionality that allows for efficient and powerful text searching capabilities. Here’s a comprehensive guide on how to utilize MongoDB’s full-text search. 1. Setting Up Mong…

【日常记录-JS】获取URL参数

Author&#xff1a;赵志乾 Date&#xff1a;2024-07-24 Declaration&#xff1a;All Right Reserved&#xff01;&#xff01;&#xff01; 1. 简介 实际项目中经常有些落地页会携带参数&#xff0c;并要求在发起请求时将携带的参数一并传递至后台服务。例如两个独立系统A和B&…

Linux系统上安装zookeeper

百度网盘 通过网盘分享的文件&#xff1a;zookeeper_linux 链接: https://pan.baidu.com/s/1_hybXZVwTRkotz0VbwbSMw?pwd8888 提取码: 8888 1.将压缩包拖进虚拟机 2.解压压缩包 cd /ruanjian/zookeeper/ tar -zxvf apache-ZooKeeper-3.7.2-bin.tar.gz3. 进入到conf目录 cd …

《python程序语言设计》第6章12题 显示字符,使用下面的函数头,编写一个打印字符的函数

def printChars(ch1, ch2, numberPerLine):a ord(ch1)b ord(ch2)count 0for i in range(a, b 1):count 1print(chr(i), end" ")if count % numberPerLine 0:print()printChars("1", "Z", 10)

以FastGPT为例提升Rag知识库应用中的检索召回命中率

提升Rag知识库应用中的检索召回命中率 在构建Rag&#xff08;Retrieval-Augmented Generation&#xff09;知识库应用时&#xff0c;检索召回知识片段的命中率是至关重要的。高效、准确的检索机制是确保AI系统能够精准响应用户查询的基础。当前&#xff0c;FastGPT主要采用三种…

使用python中的特殊字典——defaultdict

专栏总目录 一、defaultdict说明 在Python中是一个特殊类型的字典&#xff0c;它是collections模块中的一个类defaultdict的实例。这个字典与普通的字典dict不同之处在于&#xff0c;当你试图访问一个不存在的键时&#xff0c;defaultdict会自动创建一个新条目&#xff0c;其值…

使用SpringBoot集成Kafka实现用户数据变更后发送消息

概述 当使用Spring Boot集成Kafka实现用户数据变更后&#xff0c;向其他厂商发送消息&#xff0c;我们需要考虑以下步骤&#xff1a;配置Kafka连接、创建Kafka Producer发送消息、监听用户数据变更事件&#xff0c;并将事件转发到Kafka。 1. 环境准备 确保已经安装Java开发环…

【java基础】java中配置文件格式以及读取方式

在Java中&#xff0c;配置文件可以采用多种格式&#xff0c;每种格式都有其特定的使用场景和优势。以下是一些常见的配置文件格式以及如何在Java中读取它们的方法&#xff1a; 1. Properties 文件 (.properties) Properties 文件是一种常见的配置文件格式&#xff0c;它使用键…

C++沉思:预处理和编译

预处理和编译 条件编译源代码使用方式典型示例原理 使用static_assert执行编译时断言检查使用方式原理 在C中&#xff0c;编译是将源代码转换为机器代码并组织在目标文件中&#xff0c;然后将目标文件链接在一起生成可执行文件的过程。编译器实际上一次只处理一个文件&#xff…

Oracle核心进程详解并kill验证

Oracle核心进程详解并kill验证 文章目录 Oracle核心进程详解并kill验证一、说明二、核心进程详解2.1.PMON-进程监控进程2.2.SMON-系统监控进程2.3.DBWn-数据库块写入进程2.4. LGWR-日志写入器进程2.5. CKPT-检查点进程 三、Kill验证3.1.kill ckpt进程3.2.kill pmon进程3.3.kill…

智慧工地视频汇聚管理平台:打造现代化工程管理的全新视界

一、方案背景 科技高速发展的今天&#xff0c;工地施工已发生翻天覆地的变化&#xff0c;传统工地管理模式很容易造成工地管理混乱、安全事故、数据延迟等问题&#xff0c;人力资源的不足也进一步加剧了监管不到位的局面&#xff0c;严重影响了施工进度质量和安全。 视频监控…

中小企业数字化转型的关键五步,你了解吗?

在信息技术迅猛发展的当下&#xff0c;数字化转型已成为中小企业提升竞争力、实现可持续发展的关键策略。在数字化转型过程中&#xff0c;工业软件作为贯穿生产全流程的智能化引擎&#xff0c;其选择与应用显得尤为关键。那么&#xff0c;中小企业应如何科学合理的规划数字化转…

Vue前端页面嵌入mermaid图表--流程图

一、安装Mermaid 首先&#xff0c;你需要在你的项目中安装Mermaid。可以通过npm或yarn来安装&#xff1a; npm install mermaid --save # 或者 yarn add mermaid结果如图&#xff1a; 二、Vue 方法一&#xff1a;使用pre标签 使用ref属性可以帮助你在Vue组件中访问DOM元素 …

对于接口调用方式,可以使用两种不同的技术:Web Service 和 Dubbo。下面我将简要解释它们以及如何在 Maven 项目中集成它们。

对于接口调用方式&#xff0c;可以使用两种不同的技术&#xff1a;Web Service 和 Dubbo。下面我将简要解释它们以及如何在 Maven 项目中集成它们。 ### 1. Web Service&#xff08;WS&#xff09; Web Service 是一种基于标准化协议和格式进行通信的技术&#xff0c;允许不同…

数据结构 | LinkedList与链表

前言 ArrayList底层使用连续的空间,任意位置(尤其是0位置下标)插入或删除元素时,需要将该位置后序元素 整体 往前或往后搬移,故时间复杂度为O(N). 优点(给定一个下标,可以快速查找到对应的元素,时间复杂度为O(1))增容需要申请新空间,拷贝数据,释放旧空间,会有不小的消耗.增容一…