(One hundred eighty-three) learning TraceView

reference:

Android Performance Optimization: Using TraceView find the culprit Caton

Android performance optimization (a) 35% of the starting acceleration

PS: start acceleration that can sum up the lazy loading of lazy loading, lazy loading can not see can not put asynchronous, asynchronous thread rational allocation priority.

 

1. Use Android Studio to generate trace files

Android Monitor obsolete, and now with the profile

Before learning too, but for a long time do not forget. . .

https://blog.csdn.net/sinat_20059415/article/details/80584621

Suddenly I found a reference before the document is actually handling the development of the document, too, find their own way can there be so full

https://developer.android.google.cn/studio/profile/cpu-profiler

 

 

2. Using DDMS generate trace files

jiatai@jiatai:~/Android/Sdk/tools$ sudo ./monitor  
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
Error Loading DDMS Preferences

ddms obsolete

 

 

3.Systrace

If you want to collect detailed system-level data to help you check the local system processes and resolve UI jank caused by the dropped frames, you should use Systrace . Or, if you want to export using Debug captured .trace file, it should use Traceview "

Before looking blog see this, make up what is Systrace

https://developer.android.google.cn/studio/profile/systrace/command-line

Try it

jiatai@jiatai:~/Android/Sdk/platform-tools/systrace$ python systrace.py --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
        freq - CPU Frequency
        idle - CPU Idle
        disk - Disk I/O
        load - CPU Load
        sync - Synchronization
  memreclaim - Kernel Memory Reclaim
  binder_driver - Binder Kernel driver
  binder_lock - Binder global lock trace

NOTE: more categories may be available with adb root

Then caught a recommended order html

jiatai@jiatai:~/Android/Sdk/platform-tools/systrace$ python systrace.py -o mynewtrace.html sched freq idle am wm gfx view \
>         binder_driver hal dalvik camera input res
Starting tracing (stop with enter)
Tracing completed. Collecting output...
Outputting Systrace results...
Tracing complete, writing results

Wrote trace HTML file: file:///home/jiatai/Android/Sdk/platform-tools/systrace/mynewtrace.html

jiatai@jiatai:~/Android/Sdk/platform-tools/systrace$ 

 

Looked under the systrace should ddms and this script is one thing, but better graphical interface, measured the resulting file is the same

 

4.traceview

Traceview 已被弃用。 如果您使用的是 Android Studio 3.2 或更高版本,则应改为使用 CPU Profiler 来执行以下操作:检查通过使用 Debug 类对应用进行插桩检测而捕获的 .trace 文件、记录新方法跟踪信息、保存 .trace 文件以及检查应用进程的实时 CPU 使用情况。

Traceview 这款工具可采用图形的形式表示跟踪日志。您可以通过使用 Debug 类检测代码来生成日志。这种跟踪方法非常精确,因为您可以指定要在代码中开始和停止记录跟踪数据的确切位置。如果尚未生成此类跟踪日志并将其从连接的设备保存到本地计算机,请转到通过检测您的应用生成跟踪日志。使用 TraceView 检查此类日志有助于您调试应用并分析其性能。

提示:您可以从命令行使用 dmtracedump 来生成跟踪日志文件的调用堆栈图表(以图形的形式直观地呈现)。

如果您不需要查看通过使用 Debug 类检测应用而记录的跟踪日志,可以使用 Android Studio 3.0 及更高版本中包含的 CPU Profiler 来检查应用的线程并记录方法跟踪信息。

 

5.总结

cpu profiler很强大,可以抓取cpu memory等信息,可以看方法调用和时间消耗等

systrace可以抓取系统层面的trace,生成一个HTML,很复杂的样子,然后功能被profiler取代了,官方文档里可以如下操作

要开始记录跟踪数据,请从 CPU Profiler 顶部的下拉菜单中选择记录配置,然后点击 Record

可以看到官方文档图里cpu 选项中有system trace

traceview字面意思和功能官方意思都是看trace的工具,具体trace还是通过ddms抓的,还过时了,现在用之前说的cpu profiler抓了

一句话概况systrace和traceview ddms都过时了,大家一起来用profiler啊

 

 

发布了198 篇原创文章 · 获赞 65 · 访问量 16万+

Guess you like

Origin blog.csdn.net/sinat_20059415/article/details/101112144