perfetto抓取与导入
https://developer.android.com/tools/perfetto?hl=zh-cn
常用方法
抓取(分解步骤)
- adb 连接设备,adb shell 进入 shell环境执行下面命令;
- -t表示抓几秒的;
- o表示抓完输出到哪儿;
- 后面的tag表示抓取哪些信息
perfetto -o /data/misc/perfetto-traces/111.perfetto-trace -t 60s sched freq idle am wm gfx view binder_driver hal dalvik camera input res memory
- 导出perfetto,到本地
adb pull /data/misc/perfetto-traces/111.perfetto-trace .

- 浏览器打开网址,并导入文件
https://ui.perfetto.dev/

google脚本工具(合并)
google提供了原生工具给我们使用,方法如下
首先也是需要adb连接设备
// 进入源码路径
cd /src/aosp/aosp13_r6/external/perfetto/tools
// 使用工具抓取
./record_android_trace -o $(date +%Y%m%d_%H%M%S)_trace_file.perfetto-trace -t 5s -b 32mb sched freq idle am wm gfx view binder_driver hal dalvik camera input res memory gfx view wm am ss video camera hal res sync idle binder_driver binder_lock ss
- -b为文件大小限制
- -t为时间间隔
抓取后会自己打开google chrome网址
perfetto分析
线程状态
- running:运行态

-
runnable:待调度(点击可查看被唤醒时的waker process 、thread)

-
Uninterruptible Sleep:不可中断休眠(IO或者非IO)

计数值

异步执行块

跨进程调用跟踪
binder transact:同步调用,调用端
binder reply:同步调用,接收端

binder transaction async:异步调用,调用端
binder recv async:异步调用,接收端


如何自己加tag(cpp)
条件:
-
需要在mk/bp文件引入系统lib
"libutils", -
需要引入头文件
#include <utils/Trace.h> -
引入
#undef ATRACE_TAG
#

最低0.47元/天 解锁文章
7605

被折叠的 条评论
为什么被折叠?



