python: 2.7.x
安装six模块:pip install six
位置: sdk/platform-tools/systrace
systrace 命令抓取:常用的抓取方法
$ python systrace.py \
-t 5 \ # 抓取5s
-a com.android.systemui \ # 跟踪此进程
-b 2048 \ #单位KB,跟踪缓冲区大小
-o systrace.html \ #输出trace文件名称
sched freq idle am wm gfx view binder_driver hal dalvik camera input res
# 参数可用 -l查看
python systrace.py --list-categories
或
python systrace.py -l
xxx@xxx:~/Android/Sdk/platform-tools/systrace$ python systrace.py -l
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
nnapi - NNAPI
rro - Runtime Resource Overlay
pdx - PDX services
sched - CPU Scheduling
freq - CPU Frequency
idle - CPU Idle
disk - Disk I/O
sync - Synchronization
memreclaim - Kernel Memory Reclaim
binder_driver - Binder Kernel driver
binder_lock - Binder global lock trace
gfx - Graphics (HAL)
ion - ION allocation (HAL)
NOTE: more categories may be available with adb root
atrace 脚本中使用的抓取方法
开始:
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 > atrace
转换为systrace.html:
python systrace.py --from-file atrace -o a.html