赞
踩
本讲是Android Camera性能分析专题的第6讲,我们介绍如何通过perfetto抓取trace,包括如下内容:
视频在线观看:
加入知识星球与更多Camera同学交流
– 星球名称:深入浅出Android Camera
– 星球ID: 17296815
从Android P开始Android引入perfetto,在Android R才默认打开Tracing服务
打开方法
- # Needed only on Android 9 (P) and 10 (Q) on non-Pixel phones.
- adb shell setprop persist.traced.enable 1
- adb reboot
确认相关服务是否正常启动
- HWPCT:/ $ ps -A |grep -iE "traced"
- nobody 1016 1 46520 2444 0 0 S traced
- nobody 1017 1 46520 2624 0 0 S traced_probes
抓取perfetto的python脚本
/external/perfetto/tools/record_android_trace
执行抓取命令(与systrace类似)
python3 record_android_trace -o trace_file.perfetto-trace -t 10s -b 32mb -n sched freq idle am wm gfx view binder_driver hal dalvik camera input res memory
还可以指定configure文件
python3 record_android_trace -o trace_file.perfetto-trace -t 10s -b 32mb -n -c record_camera.config
执行抓取命令
- adb shell perfetto -o /data/misc/perfetto-traces/trace_file.perfetto-trace -t 10s sched freq idle am wm gfx view binder_driver hal dalvik camera input res memory
-
- adb pull /data/misc/perfetto-traces/trace_file.perfetto-trace
还可以指定Configure文件
- adb push record_camera.config /data/local/tmp/record_camera.config
-
- adb shell “cat /data/local/tmp/record_camera.config | perfetto --txt -c - -o /data/misc/perfetto-traces/trace.perfetto-trace”
-
- adb pull /data/misc/perfetto-traces/trace.perfetto-trace
在Settings中配置和打开trace
Developer options > System tracing
Show quick settings title
Pull 抓取到的trace
adb pull /data/local/traces
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。