CpuStatsCollector
public
class
CpuStatsCollector
extends Object
java.lang.Object | |
↳ | com.android.tradefed.device.CpuStatsCollector |
Helper class which runs cpustats
continuously on an ITestDevice
and parses the
output.
Provides a method to record the output of cpustats
and get all the cpu usage measurements
as well methods for performing calculations on that data to find the mean of the cpu workload,
the approximate cpu frequency, and the percentage of used cpu frequency.
This is meant to be a replacement for TopHelper
, which does not provide stats about cpu
frequency and has a higher overhead due to measuring processes/threads.
The cpustats
command was added in the Jellybean release, so this collector should only be
used for new tests.
See also:
Summary
Nested classes | |
---|---|
class |
CpuStatsCollector.CpuStats
Class for holding parsed output data for a single |
class |
CpuStatsCollector.CpuStatsReceiver
Receiver which parses the output from |
Public constructors | |
---|---|
CpuStatsCollector(ITestDevice testDevice)
Create a |
|
CpuStatsCollector(ITestDevice testDevice, int delay)
Create a |
Public methods | |
---|---|
void
|
cancel()
Cancels the |
|
getCpuStats()
Get the mapping of labels to lists of |
static
Double
|
getEstimatedMhzMean(
Get the mean of the estimated MHz for a list of |
static
Double
|
getIowPercentageMean(
Get the mean of the iow CPU usage for a list of |
static
Double
|
getIrqPercentageMean(
Get the mean of the IRQ and SIRQ CPU usage for a list of |
static
Double
|
getSystemPercentageMean(
Get the mean of the system CPU usage for a list of |
static
Double
|
getTotalPercentageMean(
Get the mean of the total CPU usage for a list of |
static
Double
|
getUsedMhzPercentageMean(
Get the mean of the used MHz for a list of |
static
Double
|
getUserPercentageMean(
Get the mean of the user and nice CPU usage for a list of |
boolean
|
isCancelled()
Gets whether the |
void
|
logToFile(File logFile)
Specify a file to log output to. |
void
|
run()
|
Public constructors
CpuStatsCollector
public CpuStatsCollector (ITestDevice testDevice)
Create a CpuStatsCollector
.
Parameters | |
---|---|
testDevice |
ITestDevice : The test device
|
CpuStatsCollector
public CpuStatsCollector (ITestDevice testDevice, int delay)
Create a CpuStatsCollector
with a delay specified.
Parameters | |
---|---|
testDevice |
ITestDevice : The test device |
delay |
int : The delay time in seconds
|
Public methods
cancel
public void cancel ()
Cancels the cpustats
command.
getCpuStats
publicgetCpuStats ()
Get the mapping of labels to lists of CpuStats
instances.
Returns | |
---|---|
|
a mapping of labels to lists of CpuStats instances. The labels will include
"Total" and "cpu0"..."cpuN" for each CPU on the device.
|
getEstimatedMhzMean
public static Double getEstimatedMhzMean (cpuStats)
Get the mean of the estimated MHz for a list of CpuStats
.
Parameters | |
---|---|
cpuStats |
: the list of CpuStats |
Returns | |
---|---|
Double |
The average estimated MHz in MHz. |
getIowPercentageMean
public static Double getIowPercentageMean (cpuStats)
Get the mean of the iow CPU usage for a list of CpuStats
.
Parameters | |
---|---|
cpuStats |
: the list of CpuStats |
Returns | |
---|---|
Double |
The average usage as a percentage (0 to 100). |
getIrqPercentageMean
public static Double getIrqPercentageMean (cpuStats)
Get the mean of the IRQ and SIRQ CPU usage for a list of CpuStats
.
Parameters | |
---|---|
cpuStats |
: the list of CpuStats |
Returns | |
---|---|
Double |
The average usage as a percentage (0 to 100). |
getSystemPercentageMean
public static Double getSystemPercentageMean (cpuStats)
Get the mean of the system CPU usage for a list of CpuStats
.
Parameters | |
---|---|
cpuStats |
: the list of CpuStats |
Returns | |
---|---|
Double |
The average usage as a percentage (0 to 100). |
getTotalPercentageMean
public static Double getTotalPercentageMean (cpuStats)
Get the mean of the total CPU usage for a list of CpuStats
.
Parameters | |
---|---|
cpuStats |
: the list of CpuStats |
Returns | |
---|---|
Double |
The average usage as a percentage (0 to 100). |
getUsedMhzPercentageMean
public static Double getUsedMhzPercentageMean (cpuStats)
Get the mean of the used MHz for a list of CpuStats
.
Parameters | |
---|---|
cpuStats |
: the list of CpuStats |
Returns | |
---|---|
Double |
The average used MHz as a percentage (0 to 100). |
getUserPercentageMean
public static Double getUserPercentageMean (cpuStats)
Get the mean of the user and nice CPU usage for a list of CpuStats
.
Parameters | |
---|---|
cpuStats |
: the list of CpuStats |
Returns | |
---|---|
Double |
The average usage as a percentage (0 to 100). |
isCancelled
public boolean isCancelled ()
Gets whether the cpustats
command is canceled.
Returns | |
---|---|
boolean |
if the cpustats command is canceled.
|
logToFile
public void logToFile (File logFile)
Specify a file to log output to.
Parameters | |
---|---|
logFile |
File : the file to log output to.
|
run
public void run ()
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2019-10-02 UTC.