本讲是android camera性能分析专题的第41讲,我们介perfetto 自动化之python sdk自动化分析性能环境搭建。
更多资源:
资源 | 描述 |
---|---|
在线课程 | |
知识星球 | 星球名称:深入浅出android camera 星球id: 17296815 |
极客笔记圈 |
搭建perfetto python sdk环境
安装perfetto库(推荐使用python3)
pip install perfetto
获取trace processor二进制文件(避免科学上网)
- 下载脚本
https://get.perfetto.dev/trace_processor
- 根据python sdk运行的操作系统环境选择trace processor二进制文件下载地址,以windows 64版本为例
https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v37.0/windows-amd64/trace_processor_shell.exe
perfetto python sdk – hello world
from perfetto.trace_processor import traceprocessor
from perfetto.trace_processor import traceprocessorconfig
tp = traceprocessor(trace='geekcamera2_camera_launch.trace',
config=traceprocessorconfig(
bin_path=r'trace_processor_shell_v3.7.exe',
verbose=false
))
qr_it = tp.query('select name,dur from slice where name="connectdevice"')
for row in qr_it:
print(row.name, row.dur / 1e6)
cpu_metrics = tp.metric(['android_startup'])
# print(cpu_metrics)
输出: