CircularAtraceUtil

public class CircularAtraceUtil
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.CircularAtraceUtil


這項公用程式主要用於找出 Monkey 測試期間發生 ANR 的根本原因。呼叫 start 指令會開始非同步監控循環緩衝區中已加上標記的追蹤記錄。呼叫 stop 會將緩衝區的內容傾印至 InputStreamSource,並傳回該內容。 如要將這項功能用於上述案例 (識別 ANR),請先在測試開始時實作 start 方法,並在測試結束時立即實作 end 方法。您可以在這裡選擇資料的儲存和處理方式。大多數人可能都應該使用 systrace,並搭配 --from-file 選項產生 HTML 檢視器。

摘要

公用建構函式

CircularAtraceUtil()

公用方法

static FileInputStreamSource endTrace(ITestDevice device)

Stops and dumps atrace asynchronously into a File, which it returns in an InputStreamSource.

static void startTrace(ITestDevice device, List<String> tags, int bufferSizeMB)

Starts atrace asynchronously with the tags specified.

公用建構函式

CircularAtraceUtil

public CircularAtraceUtil ()

公用方法

endTrace

public static FileInputStreamSource endTrace (ITestDevice device)

以非同步方式停止並傾印 atrace 至檔案,並在 InputStreamSource 中傳回該檔案。

參數
device ITestDevice

傳回
FileInputStreamSource FileInputStreamSource,其中包含 atrace 指令的結果

擲回
DeviceNotAvailableException
IllegalStateException

startTrace

public static void startTrace (ITestDevice device, 
                List<String> tags, 
                int bufferSizeMB)

使用指定的標記非同步啟動追蹤記錄。

參數
device ITestDevice:要監控動作的裝置

tags List:atrace 應監控的標記,預設為「am gfx sched view」

bufferSizeMB int:以 MB 為單位的環形緩衝區大小

擲回
DeviceNotAvailableException
IllegalStateException