adb shell atrace -c -b 10240 --async_start -z gfx
1. 執行查看adb shell atrace 功能web
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.普通抓取方法shell
adb shell "atrace gfx -b 20480 -t 1 | grep xxx/xxx.SGameActivity"
2.指向文件輸出使用app
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.不間斷循環抓取async
開始:
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