Android/Linux系统性能分析工具之-perfetto

1. 前言:

Perfetto工具是Android全新的统一的trace收集和分析框架,可以抓取平台和app的trace信息,是用来取代systrace的,但systrace由于历史原因也还会一直存在,并且Perfetto抓取的trace文件也可以同样转换成systrace视图,如果习惯用systrace的,可以用Perfetto UI的"Open with legacy UI"转换成systrace视图来看。

1.1 perfetto 文档地址:

https://perfetto.dev/docs/quickstarticon-default.png?t=M276https://perfetto.dev/docs/quickstart

1.2 perfetto UI工具地址:

Perfetto UIicon-default.png?t=M276https://ui.perfetto.dev/

1.3 perfetto 主页面

Perfetto - System profiling, app tracing and trace analysisicon-default.png?t=M276https://perfetto.dev/

1.4 Trace Viewer界面:

 

2.  如何使用

2.1 使用google python工具:record_android_trace

2.1.1 下载地址:

https://raw.githubusercontent.com/google/perfetto/master/tools/record_android_traceicon-default.png?t=M276https://raw.githubusercontent.com/google/perfetto/master/tools/record_android_trace

2.1.2 下载并使用

Linux:

下载:

curl -O https://raw.githubusercontent.com/google/perfetto/master/tools/record_android_trace

修改权限:

chmod u+x record_android_trace # See ./record_android_trace --help for more


执行:

./record_android_trace -o trace_file.perfetto-trace -t 10s -b 32mb \ sched freq idle am wm gfx view binder_driver hal dalvik camera input res memory

 Windows:

下载:

curl -O https://raw.githubusercontent.com/google/perfetto/master/tools/record_android_trace

执行:

python3 record_android_trace -o trace_file.perfetto-trace -t 10s -b 32mb \ sched freq idle am wm gfx view binder_driver hal dalvik camera input res memory     

2.2 ADB Shell 直接运行 perfetto抓取trace

运行shell:

adb shell perfetto -o /data/misc/perfetto-traces/trace_file.perfetto-trace -t 20s \ sched freq idle am wm gfx view binder_driver hal dalvik camera input res memory

2.3 通过perfetto config 抓取 trace

2.3.1 配置perfetto

 >配置完后:

> 拷贝文件,删除头跟尾

 

> 删除后,保存文件为 perfetto_config.pbtx

2.3.2  更新设备perfetto config

adb push perfetto_config.pbtx data/misc/perfetto-traces/

 2.2.3 执行,抓取trace

adb shell perfetto --txt -c data/misc/perfetto-traces/perfetto_config.pbtx -o data/misc/perfetto-traces/trace_file.perfetto-trace

 导出:

adb pull /data/misc/perfetto-traces/trace_file.perfetto-trace

2.4 分析 

用工具打开trace_file.perfetto-tracePerfetto UIicon-default.png?t=M276https://ui.perfetto.dev/#!/record

 

 

  • 2
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

村里小码农

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值