to top
public class

TopHelper

extends Thread
java.lang.Object
   ↳ java.lang.Thread
     ↳ com.android.tradefed.device.TopHelper

Class Overview

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. 
[Expand]
Inherited Constants
From class java.lang.Thread
[Expand]
Inherited Fields
From class java.lang.Thread
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
synchronized 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.
synchronized boolean isCancelled()
Gets whether the top command is canceled.
void logToFile(File logFile)
Specify a file to log the top output to.
void run()
[Expand]
Inherited Methods
From class java.lang.Thread
From class java.lang.Object
From interface java.lang.Runnable

Public Constructors

public TopHelper (ITestDevice testDevice, int delay)

Create a TopHelper instance with a delay specified.

Parameters
testDevice The device.
delay The delay time interval for the top command in seconds.

public TopHelper (ITestDevice testDevice)

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

Parameters
testDevice The device.

Public Methods

public synchronized void cancel ()

Cancels the top command.

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

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

Parameters
topStats the list of TopHelper.TopStats
Returns
  • The average usage as a percentage (0 to 100).

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

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

Parameters
topStats the list of TopHelper.TopStats
Returns
  • The average usage as a percentage (0 to 100).

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

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

Parameters
topStats the list of TopHelper.TopStats
Returns
  • The average usage as a percentage (0 to 100).

public List<TopHelper.TopStats> getTopStats ()

Gets a list of TopHelper.TopStats instances.

Returns

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

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

Parameters
topStats the list of TopHelper.TopStats
Returns
  • The average usage as a percentage (0 to 100).

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

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

Parameters
topStats the list of TopHelper.TopStats
Returns
  • The average usage as a percentage (0 to 100).

public synchronized boolean isCancelled ()

Gets whether the top command is canceled.

Returns
  • if the top command is canceled.

public void logToFile (File logFile)

Specify a file to log the top output to.

Parameters
logFile the file to lot output to.

public void run ()