安卓Systrace工具使用流程

安卓Systrace工具使用流程,第1张

安卓Systrace工具使用流程
    • 安装
    • 生成报告

标签:Systrace工具使用流程


安装

1.1.1 下载sdk-tools:
https://developer.android.com/studio/intro/update?hl=zh-cn#sdk-manager

1.1.2 安装 python 2.7.18:(注意,一定用这个版本,python3不行)

需要安装 python 2.7.18版本,下载地址: https://www.python.org/downloads/release/python-2718/

1.1.3 安装依赖

python -m pip install pywin32
python -m pip install six

1.1.4 验证

在 $ANDROID_ROOT/platform-tools/systrace目录下执行 python systrace.py -h查看帮助信息。


D:\Program Files\ADB\platform-tools_r30.0.1-windows\platform-tools\systrace> python systrace.py -h
Usage: systrace.py [options] [category1 [category2 …]]
Example: systrace.py -b 32768 -t 15 gfx input view sched freq
Options:
-h, --help show this help message and exit
-o FILE write trace output to FILE
-j, --json write a JSON file
–link-assets (deprecated)
–asset-dir=ASSET_DIR
(deprecated)
-e DEVICE_SERIAL_NUMBER, --serial=DEVICE_SERIAL_NUMBER
adb device serial number
–target=TARGET choose tracing target (android or linux)
–timeout=TIMEOUT timeout for start and stop tracing (seconds)
–collection-timeout=COLLECTION_TIMEOUT
timeout for data collection (seconds)
-t N, --time=N trace for N seconds
-b N, --buf-size=N use a trace buffer size of N KB
-l, --list-categories
list the available categories and exit
Atrace options:
–atrace-categories=ATRACE_CATEGORIES
Select atrace categories with a comma-delimited list,
e.g. --atrace-categories=cat1,cat2,cat3
-k KFUNCS, --ktrace=KFUNCS
specify a comma-separated list of kernel functions to
trace
–no-compress Tell the device not to send the trace data in
compressed form.
-a APP_NAME, --app=APP_NAME
enable application-level tracing for comma-separated
list of app cmdlines
–from-file=FROM_FILE
read the trace from a file (compressed) rather than
running a live trace
Atrace process dump options:
–process-dump Capture periodic per-process memory dumps.
–process-dump-interval=PROCESS_DUMP_INTERVAL_MS
Interval between memory dumps in milliseconds.
–process-dump-full=PROCESS_DUMP_FULL_CONFIG
Capture full memory dumps for some processes. Value:
all, apps or comma-separated process names.
–process-dump-mmaps
Capture VM regions and memory-mapped files. It
increases dump size dramatically, hence only has
effect if --process-dump-full is a whitelist.
Ftrace options:
–ftrace-categories=FTRACE_CATEGORIES
Select ftrace categories with a comma-delimited list,
e.g. --ftrace-categories=cat1,cat2,cat3
WALT trace options:
–walt Use the WALT tracing agent. WALT is a device for
measuring latency of physical sensors on phones and
computers. See https://github.com/google/walt


生成报告

以下就是抓取com.abc. testmain1 60s内的数据

python systrace.py -t 60 sched gfx view wm am app webview -a com.abc. testmain1

备注:60秒生成154M大小文件,文件较大

PC上打开Chrome浏览器
在chrome地址栏中输入”chrome:tracing”,然后点击load按钮load你的trace.html文件。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/569431.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-09
下一篇 2022-04-09

发表评论

登录后才能评论

评论列表(0条)

保存