日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

systrace html空白,Android性能优化之Systrace工具介绍(一) _ Systrace生成的trace.html打开空白或者打不开的解决办法...

發布時間:2023/12/4 Android 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 systrace html空白,Android性能优化之Systrace工具介绍(一) _ Systrace生成的trace.html打开空白或者打不开的解决办法... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.必須用Chrome打開

2.在mac電腦上,可能Chrome打開也是空白,解決辦法是:在chrome地址欄中輸入”chrome:tracing”,然后點擊load按鈕load你的trace.html文件。

Systrace簡單介紹

Systrace是Android4.1中新增的性能數據采樣和分析工具。它可幫助開發者收集Android關鍵子系統(如surfaceflinger、WindowManagerService等Framework部分關鍵模塊、服務,View系統等)的運行信息,從而幫助開發者更直觀的分析系統瓶頸,改進性能。

Systrace的功能包括跟蹤系統的I/O操作、內核工作隊列、CPU負載以及Android各個子系統的運行狀況等。在Android平臺中,它主要由3部分組成:

內核部分:Systrace利用了Linux Kernel中的ftrace功能。所以,如果要使用Systrace的話,必須開啟kernel中和ftrace相關的模塊。

數據采集部分:Android定義了一個Trace類。應用程序可利用該類把統計信息輸出給ftrace。同時,Android還有一個atrace程序,它可以從ftrace中讀取統計信息然后交給數據分析工具來處理。

數據分析工具:Android提供一個systrace.py(python腳本文件,位于Android SDK目錄/tools/systrace中,其內部將調用atrace程序)用來配置數據采集的方式(如采集數據的標簽、輸出文件名等)和收集ftrace統計數據并生成一個結果網頁文件供用戶查看。 從本質上說,Systrace是對Linux Kernel中ftrace的封裝。應用進程需要利用Android提供的Trace類來使用Systrace.

關于Systrace的官方介紹和使用可以看這里:Systrace

Systrace簡單使用

使用Systrace前,要先了解一下Systrace在各個平臺上的使用方法,鑒于大家使用Eclipse和Android Studio的居多,所以直接摘抄官網關于這個的使用方法,不過不管是什么工具,流程是一樣的:

手機準備好你要進行抓取的界面

點擊開始抓取(命令行的話就是開始執行命令)

手機上開始操作

設定好的時間到了之后,會將生成Trace文件,使用Chrome將這個文件打開進行分析

Using?Eclipse

In Eclipse, open an Android application project.

Switch to the DDMS perspective, by selecting Window > Perspectives > DDMS.

In the Devices tab, select the device on which to run a trace. If no devices are listed, make sure your device is connected via USB cable and that debugging is enabled on the device.

Click the Systrace icon at the top of the Devices panel to configure tracing.

Set the tracing options and click OK to start the trace.

Using?Android Studio

In Android Studio, open an Android application project.

Open the Device Monitor by selecting Tools > Android > Monitor.

In the Devices tab, select the device on which to run a trace. If no devices are listed, make sure your device is connected via USB cable and that debugging is enabled on the device.

Click the Systrace icon at the top of the Devices panel to configure tracing.

Set the tracing options and click OK to start the trace.

Using?Device Monitor

Navigate to your SDK tools/ directory.

Run the monitor program.

In the Devices tab, select the device on which to run a trace. If no devices are listed, make sure your device is connected via USB cable and that debugging is enabled on the device.

Click the Systrace icon at the top of the Devices panel to configure tracing.

Set the tracing options and click OK to start the trace.

Command Line Usage

命令行形式比較靈活,速度也比較快,一次性配置好之后,以后再使用的時候就會很快就出結果(強烈推薦)

1

2

$ cd android-sdk/platform-tools/systrace

$ python systrace.py --time=10 -o mynewtrace.html sched gfx view wm

從上面的命令可以看到Systrace工具的位置,只需要在Bash中配置好對應的路徑和Alias,使用起來還是很快速的。另外User版本是不可以抓Trace的,只有ENG版本或者Userdebug版本才可以。

抓取結束后,會生成對應的Trace文件,注意這個文件只能被Chrome打開。關于如何分析Trace文件,我們下面的章節會講。不論使用那種工具,在抓取之前都會讓選擇參數,下面說一下這些參數的意思:

-h, –help Show the help message.(幫助)

-o Write the HTML trace report to the specified file.(即輸出文件名,)

-t N, –time=N Trace activity for N seconds. The default value is 5 seconds. (Trace抓取的時間,一般是 : -t 8)

-b N, –buf-size=N Use a trace buffer size of N kilobytes. This option lets you limit the total size of the data collected during a trace.

-k

—ktrace= Trace the activity of specific kernel functions, specified in a comma-separated list.

-l, –list-categories List the available tracing category tags. The available tags are(下面的參數不用翻譯了估計大家也看得懂,貼官方的解釋也會比較權威,后面分析的時候我們會看到這些參數的作業的):

gfx?- Graphics

input?- Input

view?- View

webview - WebView

wm?- Window Manager

am?- Activity Manager

audio - Audio

video - Video

camera - Camera

hal - Hardware Modules

res - Resource Loading

dalvik?- Dalvik VM

rs - RenderScript

sched?- CPU Scheduling

freq?- CPU Frequency

membus?- Memory Bus Utilization

idle?- CPU Idle

disk?- Disk input and output

load?- CPU Load

sync?- Synchronization Manager

workq?- Kernel Workqueues Note: Some trace categories are not supported on all devices. Tip: If you want to see the names of tasks in the trace output, you must include the sched category in your command parameters.

-a

—app= Enable tracing for applications, specified as a comma-separated list of package names. The apps must contain tracing instrumentation calls from the Trace class. For more information, see Analyzing Display and Performance.

—link-assets Link to the original CSS or JavaScript resources instead of embedding them in the HTML trace report.

—from-file= Create the interactive Systrace report from a file, instead of running a live trace.

—asset-dir= Specify a directory for the trace report assets. This option is useful for maintaining a single set of assets for multiple Systrace reports.

-e

—serial= Conduct the trace on a specific connected device, identified by its device serial number.

上面的參數雖然比較多,但使用工具的時候不需考慮這么多,在對應的項目前打鉤即可,命令行的時候才會去手動加參數:

我們一般會把這個命令配置成Alias,配置如下:

1

2

alias st-start='python /home/gaojianwu/Software/android-studio/sdk/platform-tools/systrace/systrace.py' alias st-start-gfx-trace = ‘st-start -t 8 gfx input view sched freq wm am hwui workq res dalvik sync disk load perf hal rs idle mmc’

這樣在使用的時候,可以直接敲?st-start-gfx-mx4?即可,當然為了區分和保持各個文件,還需要加上?-o xxx.Trace?.上面的命令和參數不必一次就理解,只需要記住如何簡單使用即可,在分析的過程中,這些東西都會慢慢熟悉的。

轉自:http://blog.csdn.net/hard_working1/article/details/50602345

總結

以上是生活随笔為你收集整理的systrace html空白,Android性能优化之Systrace工具介绍(一) _ Systrace生成的trace.html打开空白或者打不开的解决办法...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。