TopHelper

public class TopHelper
extends Thread

java.lang.Object
   ↳ java.lang.Thread
     ↳ 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

enum TopHelper.PercentCategory

Enum used for distinguishing between the various percentages in the top output. 

class TopHelper.TopReceiver

Receiver which parses the output from top. 

class TopHelper.TopStats

Class for holding the parsed output for a single top output. 

Public constructors

TopHelper(ITestDevice testDevice, int delay)

Create a TopHelper instance with a delay specified.

TopHelper(ITestDevice testDevice)

Create a TopHelper instance with a default delay of 1 second.

Public methods

void cancel()

Cancels the top command.

static Double getIowAverage(List<TopHelper.TopStats> topStats)

Get the average IOW CPU usage for a list of TopHelper.TopStats.

static Double getIrqAverage(List<TopHelper.TopStats> topStats)

Get the average IRQ CPU usage for a list of TopHelper.TopStats.

static Double getSystemAverage(List<TopHelper.TopStats> topStats)

Get the average system CPU usage for a list of TopHelper.TopStats.

List<TopHelper.TopStats> getTopStats()

Gets a list of TopHelper.TopStats instances.

static Double getTotalAverage(List<TopHelper.TopStats> topStats)

Get the average total CPU usage for a list of TopHelper.TopStats.

static Double getUserAverage(List<TopHelper.TopStats> topStats)

Get the average user CPU usage for a list of TopHelper.TopStats.

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

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

TopHelper (ITestDevice testDevice)

Create a TopHelper instance with a default delay of 1 second.

Parameters
testDevice ITestDevice: The device.

Public methods

cancel

void cancel ()

Cancels the top command.

getIowAverage

Double getIowAverage (List<TopHelper.TopStats> topStats)

Get the average IOW CPU usage for a list of TopHelper.TopStats.

Parameters
topStats List: the list of TopHelper.TopStats

Returns
Double The average usage as a percentage (0 to 100).

getIrqAverage

Double getIrqAverage (List<TopHelper.TopStats> topStats)

Get the average IRQ CPU usage for a list of TopHelper.TopStats.

Parameters
topStats List: the list of TopHelper.TopStats

Returns
Double The average usage as a percentage (0 to 100).

getSystemAverage

Double getSystemAverage (List<TopHelper.TopStats> topStats)

Get the average system CPU usage for a list of TopHelper.TopStats.

Parameters
topStats List: the list of TopHelper.TopStats

Returns
Double The average usage as a percentage (0 to 100).

getTopStats

List<TopHelper.TopStats> getTopStats ()

Gets a list of TopHelper.TopStats instances.

Returns
List<TopHelper.TopStats> a list of TopHelper.TopStats instances ordered from oldest to newest.

getTotalAverage

Double getTotalAverage (List<TopHelper.TopStats> topStats)

Get the average total CPU usage for a list of TopHelper.TopStats.

Parameters
topStats List: the list of TopHelper.TopStats

Returns
Double The average usage as a percentage (0 to 100).

getUserAverage

Double getUserAverage (List<TopHelper.TopStats> topStats)

Get the average user CPU usage for a list of TopHelper.TopStats.

Parameters
topStats List: the list of TopHelper.TopStats

Returns
Double The average usage as a percentage (0 to 100).

isCancelled

boolean isCancelled ()

Gets whether the top command is canceled.

Returns
boolean if the top command is canceled.

logToFile

void logToFile (File logFile)

Specify a file to log the top output to.

Parameters
logFile File: the file to lot output to.

run

void run ()