Rockchip Android平台Atrace使用方法介绍

Rockchip Android平台Atrace使用方法介绍

  1. 适用环境确认
  • Android平台
  • 设备内有atrce程序
255|rk3588_s:/ # atrace --help                                                                                                                                                       
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.
rk3588_s:/ # 
  1. 链接设备
  • 通过USB口ADB链接设计
  • 通过debug串口链接设备
  1. trace 抓取参数列表
rk3588_s_evb2:/ # 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
       nnapi - NNAPI
         rro - Runtime Resource Overlay
         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
        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
      memory - Memory
     thermal - Thermal event
  1. Rockchip Android平台抓取trace实例
    4.1. 运行atrace抓取trace
adb shell
1|rk3588_s:/ # su
130|rk3588_s:/ #  atrace -t 20 -a com.ss.andro.ugc.aweme wm am sched view res ss disk load network database -o /sdcard/a.trace

4.2. 导出atrace文件

adb pull sdcard/a.trace ./

4.3. 使用systrace.py将atrace文件转换成html文件
进入Android工程的external/chromium-trace目录,执行如下命令

xxx@ubuntu:~/Android11_sdk/external/chromium-trace$
./systrace.py --from-file a.trace -o c.html 

4.4. 使用chrome浏览器打开html文件
在chrome浏览器中输入网址:

chrome://tracing/

导入trace的html文件
Rockchip Android平台Atrace使用方法介绍_第1张图片
导入后就可以开始分析了
Rockchip Android平台Atrace使用方法介绍_第2张图片

你可能感兴趣的:(Android,android,java,性能优化)