跳转至

CLI 命令参考

perfetto-cli 所有命令和选项的完整参考。

全局选项

以下选项适用于所有分析命令:

选项 说明 默认值
-t, --trace <path> Trace 文件路径 必填
-p, --process <name> 进程名过滤
-f, --format <type> 输出格式:text / table / json text
-v, --verbose 详细输出 关闭
--tp-path <path> 自定义 trace_processor 路径 自动
--version 显示版本号并退出
--help 显示帮助并退出

anr

anr detect

检测 ANR 事件并进行严重程度分级。

perfetto-cli -t <trace> -p <process> anr detect [OPTIONS]
选项 说明 默认值
--min-duration <ms> 最小 ANR 持续时间

anr root-cause

多信号 ANR 根因分析。

perfetto-cli -t <trace> -p <process> anr root-cause [OPTIONS]
选项 说明 默认值
--anr-timestamp <ms> ANR 事件时间戳 必填

frame

frame jank

检测卡顿帧并分级。

perfetto-cli -t <trace> -p <process> frame jank [OPTIONS]
选项 说明 默认值
--threshold <ms> 卡顿阈值(毫秒) 16

frame summary

帧性能汇总及评分。

perfetto-cli -t <trace> -p <process> frame summary

cpu

cpu utilization

按线程 CPU 利用率。

perfetto-cli -t <trace> -p <process> cpu utilization [OPTIONS]
选项 说明 默认值
--include-frequency 包含 DVFS 频率信息 关闭

cpu hotspots

主线程热点切片(按耗时排序 Top-N)。

perfetto-cli -t <trace> -p <process> cpu hotspots [OPTIONS]
选项 说明 默认值
--limit <n> 显示最大热点数 20

cpu contention

线程竞争分析。

perfetto-cli -t <trace> -p <process> cpu contention

memory

memory leak

基于 RSS 的内存泄漏检测。

perfetto-cli -t <trace> -p <process> memory leak [OPTIONS]
选项 说明 默认值
--growth-threshold <MB/min> 最小增长率 5

memory heap

堆支配树分析。

perfetto-cli -t <trace> -p <process> memory heap

binder

binder profile

Binder 事务性能分析。

perfetto-cli -t <trace> -p <process> binder profile [OPTIONS]
选项 说明 默认值
--min-latency <ms> 最小延迟 10
--group-by <field> 分组:aidl / server / none none

query

query sql

执行 PerfettoSQL 查询。

perfetto-cli -t <trace> query sql [OPTIONS]
选项 说明
--query <sql> SQL 查询字符串
--file <path> SQL 文件路径

query find-slices

按模式搜索切片。

perfetto-cli -t <trace> query find-slices [OPTIONS]
选项 说明 默认值
--pattern <text> 搜索模式 必填
--match-type <type> contains / exact / glob contains

query slice-info

获取切片详情。

perfetto-cli -t <trace> query slice-info --slice-id <id>

trace

trace start

开始设备 trace 抓取。

perfetto-cli trace start [OPTIONS]
选项 说明 默认值
--duration <time> 抓取时长 10s
--buffer-size <size> 缓冲区大小 32mb

trace stop

停止抓取并拉取文件。

perfetto-cli trace stop

trace run

一键抓取。

perfetto-cli trace run [OPTIONS]
选项 说明 默认值
--duration <time> 抓取时长 10s
-o, --output <dir> 输出目录 当前目录

skills

skills install

安装技能。

perfetto-cli skills install <source>

skills list

列出已安装技能。

perfetto-cli skills list

skills uninstall

移除技能。

perfetto-cli skills uninstall <name>