systrace 概要

参考文档

https://www.jianshu.com/p/11ba656aee11
https://blog.csdn.net/xiaohua0877/article/details/78597450
http://gityuan.com/2016/01/17/systrace/
https://www.jianshu.com/p/fa6cfad8ccc2

备注

1:生成的trace信息里如果包含 “did not finish”,说明抓取的trace信息不全,此抓取无效。
2:需要使用64位的chrome浏览器打开trace文件。

3:如何分析systrace
CPU Clock Frequency这个TAG只有在变化时,才会采集在浏览器显示出来。
systrace分析必须要结合 应用场景的关键流程 分析
thermal温控也会导致CPU降频,所以可以 关掉thermal机制来测试
工作线程分配到小核运行也可能导致线程运行时间长
工作线程状态:running、sleeping、uninterruptible sleeping、runnable

4:adb shell am start -n com.qualcomm.qti.perfdump/.MainActivity // 高通平台离线抓取systrace工具

5:如何抓取开机时systrace log?
kba-170728081456_1_how_to_capture_systrace_logs_in_android-n_and_above_device.pdf

如何抓取systrace?

  1. 安装python,JDK。下载android studio,通过android studio下载android SDK包。
    使用\platform-tools\systrace\systrace.py抓取systrace,或者使用\tools\monitor.bat android device monitor抓取systrace。

android device monitor里调整java heap大小(如果出现java heap错误 或者 trace数据出现did not finish)

抓取systrace的脚本:

set time_hh=%time:~0,2%
if /i %time_hh% LSS 10 (set time_hh=0%time:~1,1%)
set filename=%date:~,4%%date:~5,2%%date:~8,2%_%time_hh%%time:~3,2%%time:~6,2%

adb root
adb shell "echo 327680 > /sys/kernel/debug/tracing/buffer_size_kb"

#python systrace.py --time=5 -b 20480 -o D:\trace\627-systrace-%filename%.html freq workq sched idle gfx input view am pm wm hal disk mmc dalvik sm irq

#python systrace.py --time=15 -b 20480 -o trace_cpu.html freq sched pm disk mmc dalvik
python systrace.py --time=25 -b 20480 -o trace_cpu2.html freq sched pm disk mmc dalvik

pause
category list:

         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
        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

NOTE: more categories may be available with adb root
posted @ 2020-12-05 16:38  bobfly1984  阅读(367)  评论(0编辑  收藏  举报