Metrics

public class Metrics
extends Object

java.lang.Object
   ↳ com.android.tradefed.testtype.metricregression.Metrics


A metrics object to hold run metrics and test metrics parsed by MetricsXmlParser

Summary

Nested classes

class Metrics.MetricsException

Throw when metrics validation fails in strict mode. 

Public constructors

Metrics(boolean strictMode)

Constructs an empty Metrics object.

Public methods

void addRunMetric(String name, String value)

Adds a run metric.

void addTestMetric(TestDescription testId, String name, String value)

Adds a test metric.

void crossValidate(Metrics after)

Validates with after-patch Metrics object.

int getNumRuns()

Gets the number of test runs stored in this object.

int getNumTests()

Gets the number of tests stored in this object.

MultiMap<String, Double> getRunMetrics()

Gets all run metrics stored in this object.

MultiMap<Pair<TestDescription, String>, Double> getTestMetrics()

Gets all test metrics stored in this object.

void setNumTests(int numTests)

Sets the number of tests.

void validate(int numRuns)

Validates that the number of entries of each metric equals to the number of runs.

Public constructors

Metrics

public Metrics (boolean strictMode)

Constructs an empty Metrics object.

Parameters
strictMode boolean: whether exception should be thrown when validation fails

Public methods

addRunMetric

public void addRunMetric (String name, 
                String value)

Adds a run metric.

Parameters
name String: metric name

value String: metric value

addTestMetric

public void addTestMetric (TestDescription testId, 
                String name, 
                String value)

Adds a test metric.

Parameters
testId TestDescription: TestDescription of the metric

name String: metric name

value String: metric value

crossValidate

public void crossValidate (Metrics after)

Validates with after-patch Metrics object. Make sure two metrics object contain same run metric entries and test metric entries. Assume this object contains before-patch metrics.

Parameters
after Metrics: a Metrics object containing after-patch metrics

Throws
Metrics.MetricsException when cross validation fails in strict mode

getNumRuns

public int getNumRuns ()

Gets the number of test runs stored in this object.

Returns
int number of test runs

getNumTests

public int getNumTests ()

Gets the number of tests stored in this object.

Returns
int number of tests

getRunMetrics

public MultiMap<String, Double> getRunMetrics ()

Gets all run metrics stored in this object.

Returns
MultiMap<String, Double> a MultiMap from test name String to Double

getTestMetrics

public MultiMap<Pair<TestDescription, String>, Double> getTestMetrics ()

Gets all test metrics stored in this object.

Returns
MultiMap<Pair<TestDescription, String>, Double> a MultiMap from (TestDescription, test name) pair to Double

setNumTests

public void setNumTests (int numTests)

Sets the number of tests. This method also checks if each call sets the same number of test, since this number should be consistent across multiple runs.

Parameters
numTests int: the number of tests

Throws
Metrics.MetricsException if subsequent calls set a different number.

validate

public void validate (int numRuns)

Validates that the number of entries of each metric equals to the number of runs.

Parameters
numRuns int: number of runs

Throws
Metrics.MetricsException when validation fails in strict mode