TopHelper
public
class
TopHelper
extends Object
java.lang.Object | |
↳ | com.android.tradefed.device.TopHelper |
Helper class which runs top continuously on an ITestDevice
and parses the output.
Provides a method to record the output of top and get all recorded CPU usage measurements or an average of a specified range of measurements. Note that top can cause approximately a 10% overhead to the CPU usage while running, so results will not be entirely accurate.
Summary
Nested classes | |
---|---|
class |
TopHelper.TopStats
Class for holding the parsed output for a single top output. |
Public constructors | |
---|---|
TopHelper(ITestDevice testDevice, int delay)
Create a |
|
TopHelper(ITestDevice testDevice)
Create a |
Public methods | |
---|---|
void
|
cancel()
Cancels the top command. |
static
Double
|
getIowAverage(
Get the average IOW CPU usage for a list of |
static
Double
|
getIrqAverage(
Get the average IRQ CPU usage for a list of |
static
Double
|
getSystemAverage(
Get the average system CPU usage for a list of |
|
getTopStats()
Gets a list of |
static
Double
|
getTotalAverage(
Get the average total CPU usage for a list of |
static
Double
|
getUserAverage(
Get the average user CPU usage for a list of |
boolean
|
isCancelled()
Gets whether the top command is canceled. |
void
|
logToFile(File logFile)
Specify a file to log the top output to. |
void
|
run()
|
Public constructors
TopHelper
public TopHelper (ITestDevice testDevice, int delay)
Create a TopHelper
instance with a delay specified.
Parameters | |
---|---|
testDevice |
ITestDevice : The device. |
delay |
int : The delay time interval for the top command in seconds.
|
TopHelper
public TopHelper (ITestDevice testDevice)
Create a TopHelper
instance with a default delay of 1 second.
Parameters | |
---|---|
testDevice |
ITestDevice : The device.
|
Public methods
cancel
public void cancel ()
Cancels the top command.
getIowAverage
public static Double getIowAverage (topStats)
Get the average IOW CPU usage for a list of TopStats
.
Parameters | |
---|---|
topStats |
: the list of TopStats |
Returns | |
---|---|
Double |
The average usage as a percentage (0 to 100). |
getIrqAverage
public static Double getIrqAverage (topStats)
Get the average IRQ CPU usage for a list of TopStats
.
Parameters | |
---|---|
topStats |
: the list of TopStats |
Returns | |
---|---|
Double |
The average usage as a percentage (0 to 100). |
getSystemAverage
public static Double getSystemAverage (topStats)
Get the average system CPU usage for a list of TopStats
.
Parameters | |
---|---|
topStats |
: the list of TopStats |
Returns | |
---|---|
Double |
The average usage as a percentage (0 to 100). |
getTopStats
publicgetTopStats ()
Gets a list of TopStats
instances.
Returns | |
---|---|
|
a list of TopStats instances ordered from oldest to newest.
|
getTotalAverage
public static Double getTotalAverage (topStats)
Get the average total CPU usage for a list of TopStats
.
Parameters | |
---|---|
topStats |
: the list of TopStats |
Returns | |
---|---|
Double |
The average usage as a percentage (0 to 100). |
getUserAverage
public static Double getUserAverage (topStats)
Get the average user CPU usage for a list of TopStats
.
Parameters | |
---|---|
topStats |
: the list of TopStats |
Returns | |
---|---|
Double |
The average usage as a percentage (0 to 100). |
isCancelled
public boolean isCancelled ()
Gets whether the top command is canceled.
Returns | |
---|---|
boolean |
if the top command is canceled. |
logToFile
public void logToFile (File logFile)
Specify a file to log the top output to.
Parameters | |
---|---|
logFile |
File : the file to lot 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.