ResourceMetricUtil

public class ResourceMetricUtil
extends Object

java.lang.Object
   ↳ com.android.tradefed.monitoring.collector.ResourceMetricUtil


用於撰寫指標的公用函式。

摘要

公用建構函式

ResourceMetricUtil()

公用方法

static float ConvertedMetricValue(String original, float conversionDivisor)

將指標值轉換為不同單位,並設定輸出值的格式。

static Optional<String> GetCommandResponse(IDeviceManager deviceManager, String serial, String cmd, long timeoutMs)

執行 adb 指令,並在成功時傳回回應。

static Timestamp GetCurrentTimestamp()

從系統 UTC 時鐘取得目前的時間戳記。

static float RoundedMetricValue(String original)

剖析指標值並設定格式。

公用建構函式

ResourceMetricUtil

public ResourceMetricUtil ()

公用方法

ConvertedMetricValue

public static float ConvertedMetricValue (String original, 
                float conversionDivisor)

將指標值轉換為不同單位,並設定輸出值的格式。

參數
original String:原始值字串。

conversionDivisor float:單位換算的除數。

傳回
float 輸出浮點數值。

擲回
NumberFormatException 如果原始字串為空值。

GetCommandResponse

public static Optional<String> GetCommandResponse (IDeviceManager deviceManager, 
                String serial, 
                String cmd, 
                long timeoutMs)

執行 adb 指令,並在成功時傳回回應。

參數
deviceManager IDeviceManager:用於在「可用」裝置上執行指令的 IDeviceManager 執行個體。

serial String:裝置序號。

cmd String:指令字串。

timeoutMs long:等待時間 (以毫秒為單位)。

傳回
Optional<String> CommandResult 執行個體。

GetCurrentTimestamp

public static Timestamp GetCurrentTimestamp ()

從系統世界標準時間時鐘取得目前的時間戳記。

傳回
Timestamp

RoundedMetricValue

public static float RoundedMetricValue (String original)

剖析指標值並設定格式。

參數
original String:原始值字串。

傳回
float 輸出浮點數值。

擲回
NumberFormatException 如果原始字串為空值。