我想在进行自动化测试时在我的 Android 手机上捕获 Systrace 报告。不知道测试需要多长时间,所以我无法为 Systrace 指定--time时间段。
深入研究systrace.py,我发现systrace正在使用atrace来获取内核日志。
我使用adb shell atrace --help
并得到以下输出:
usage: atrace [options] [categories...]
options include:
-a appname enable app-level tracing for a comma separated list of cmdlines
-b N use a trace buffer size of N KB
-c trace into a circular buffer
-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 [defualt 5]
-z compress the trace dump
--async_start start circular trace and return immediatly
--async_dump dump the current contents of circular trace buffer
--async_stop stop tracing and dump the current contents of circular
trace buffer
--list_categories
list the available tracing categories
如何使用atrace在我的自动化测试开始时开始跟踪,并在我的自动化测试结束时停止跟踪和转储内核日志?
我尝试使用以下命令,但我认为它不能正常工作。只有 async_dump 在日志中给了我一些数据。async_stop 转储在日志中没有任何内容。如何正确启动跟踪,转储它,然后停止它?
adb shell atrace -b 10000 -c am shedgfx view --async_start > C:\Users\user1\Desktop\log.txt
adb shell atrace -b 10000 -c am shedgfx view --async_dump > C:\Users\user1\Desktop\log.txt
adb shell atrace -b 10000 -c am shedgfx view --async_stop > C:\Users\user1\Desktop\log.txt