日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

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

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

1.必須用Chrome打開

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

Systrace簡單介紹

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

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

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

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

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

關(guān)于Systrace的官方介紹和使用可以看這里:Systrace

Systrace簡單使用

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

手機準(zhǔn)備好你要進(jìn)行抓取的界面

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

手機上開始操作

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

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

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

1

2

$ cd android-sdk/platform-tools/systrace

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

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

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

-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(下面的參數(shù)不用翻譯了估計大家也看得懂,貼官方的解釋也會比較權(quán)威,后面分析的時候我們會看到這些參數(shù)的作業(yè)的):

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.

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

我們一般會把這個命令配置成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?即可,當(dāng)然為了區(qū)分和保持各個文件,還需要加上?-o xxx.Trace?.上面的命令和參數(shù)不必一次就理解,只需要記住如何簡單使用即可,在分析的過程中,這些東西都會慢慢熟悉的。

轉(zhuǎn)自:http://blog.csdn.net/hard_working1/article/details/50602345

總結(jié)

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

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。