使用adb 命令(atrace)抓起systrace的方法。【转】
本文转载自:https://www.cnblogs.com/liuliu-word/p/9963017.html
adb shell atrace -c -b 10240 --async_start -z gfx
1. 执行查看adb shell atrace 功能
atrace --h
atrace: invalid option -- h usage: atrace [options] [categories...] options include: -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 of stdout.
atrace --list_categories 列出连接设备可用的跟踪类别参数(后面分析会看到这些参数)。
atrace --list_categories gfx - Graphics input - Input view - View System webview - WebView wm - Window Manager am - Activity Manager sm - Sync Manager audio - Audio video - Video camera - Camera hal - Hardware Modules res - Resource Loading dalvik - Dalvik VM rs - RenderScript bionic - Bionic C Library power - Power Management pm - Package Manager ss - System Server database - Database network - Network adb - ADB vibrator - Vibrator aidl - AIDL calls pdx - PDX services sched - CPU Scheduling irq - IRQ Events i2c - I2C Events freq - CPU Frequency idle - CPU Idle disk - Disk I/O mmc - eMMC commands load - CPU Load sync - Synchronization workq - Kernel Workqueues memreclaim - Kernel Memory Reclaim regulators - Voltage and Current Regulators binder_driver - Binder Kernel driver binder_lock - Binder global lock trace pagecache - Page cache
1.普通抓取方法
adb shell "atrace gfx -b 20480 -t 1 | grep xxx/xxx.SGameActivity"
2.指向文件输出使用
adb shell atrace -c -b 10240 --async_start -z gfx input view wm am sched load idle freq
adb shell atrace -c -b 10240 --async_stop -z gfx input view wm am sched load idle freq > d:/trace_raw
或者
adb shell "atrace gfx -b 20480 -t 1 | grep xxx/xxx.SGameActivity" > d:/trace_raw
3.不间断循环抓取
开始:
adb shell atrace -c -b 10240 --async_start gfx
执行循环输出
adb shell atrace -c -b 10240 --async_dump gfx
停止
adb shell atrace -c -b 10240 --async_stop