您现在的位置是:首页 >技术教程 >安卓性能分析工具systrace /atrace网站首页技术教程

安卓性能分析工具systrace /atrace

feihuiwu123 2024-06-14 17:20:06
简介安卓性能分析工具systrace /atrace

1.网上说的需要安装python2.7--不需要。 sytrace只是客户端,执行的还是Android atrace,所以不需要strace.py

1.检查安卓上面是否有atrace工具 win+r打开cmd输入 adb shell atrace。如果有如下日志
capturing trace...说明设备上有atrace

2.adb shell atrace  view am wm freq idle sync sched aidl gfx -t 2 -a 你的包名 > trace.html

        上一行命令">"符号是windows输出到trace.html,如果是android本地用 -o /data/xxx.html

3.trace文件查看工具

https://ui.perfetto.dev/

其他:atrace 帮助文档

adb shell atrace --list_categories

-a appname enable app-level tracing for a comma separated list of cmdlines; * is a wildcard matching any process
-b N use a trace buffer size of N KB
-c trace into a circular buffer
-f filename use the categories written in a file as space-separated
values in a line
-k fname,... trace the listed kernel functions
-n ignore signals
-s N sleep for N seconds before tracing [default 0]
-t N trace for N seconds [default 5]
-z compress the trace dump
--async_start start circular trace and return immediately
--async_dump dump the current contents of circular trace buffer
--async_stop stop tracing and dump the current contents of circular
trace buffer
--stream stream trace to stdout as it enters the trace buffer
Note: this can take significant CPU time, and is best
used for measuring things that are not affected by
CPU performance, like pagecache usage.
--list_categories
list the available tracing categories
-o filename write the trace to the specified file instead

风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。