MetricUtility

public class MetricUtility
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.MetricUtility


Contains common utility methods for storing the test metrics, aggregating the metrics in similar tests and writing the metrics to a file.

Summary

Public constructors

MetricUtility()

Public methods

aggregateMetrics( rawMetrics)

Aggregate comma separated metrics.

File aggregateStoredTestMetricsAndWriteToFile(String fileName)

Aggregate the metrics collected from multiple iterations of the test and write the aggregated metrics to a test result file.

void buildMetricFilterPatterns( strictIncludeRegEx)

Build regular expression patterns to filter the metrics.

filterMetrics( parsedMetrics)

Filter the metrics that matches the pattern.

static getStats( values, percentiles)

Compute the stats from the give list of values.

getStoredTestMetric()
static boolean isAllDoubleValues( rawValues)

Return true is all the values can be parsed to double value.

void setIterationSeparator(String separator)
void setPercentiles( percentiles)
void storeTestMetrics(TestDescription testDescription, testMetrics)

Used for storing the individual test metrics and use it for aggregation.

File writeResultsToFile(String testFileSuffix, String testHeaderName, metrics, File resultsFile)

Write metrics to a file.

Public constructors

MetricUtility

public MetricUtility ()

Public methods

aggregateMetrics

public  aggregateMetrics ( rawMetrics)

Aggregate comma separated metrics.

Parameters
rawMetrics : metrics collected during the test run.

Returns
aggregated metrics.

aggregateStoredTestMetricsAndWriteToFile

public File aggregateStoredTestMetricsAndWriteToFile (String fileName)

Aggregate the metrics collected from multiple iterations of the test and write the aggregated metrics to a test result file.

Parameters
fileName String: file name to use while writing the metrics.

Returns
File

buildMetricFilterPatterns

public void buildMetricFilterPatterns ( strictIncludeRegEx)

Build regular expression patterns to filter the metrics.

Parameters
strictIncludeRegEx

filterMetrics

public  filterMetrics ( parsedMetrics)

Filter the metrics that matches the pattern.

Parameters
parsedMetrics

Returns

getStats

public static  getStats ( values, 
                 percentiles)

Compute the stats from the give list of values.

Parameters
values : raw values to compute the aggregation.

percentiles : stats to include in the final metrics.

Returns
aggregated values.

getStoredTestMetric

public  getStoredTestMetric ()

Returns

isAllDoubleValues

public static boolean isAllDoubleValues ( rawValues)

Return true is all the values can be parsed to double value. Otherwise return false.

Parameters
rawValues : list whose values are validated.

Returns
boolean

setIterationSeparator

public void setIterationSeparator (String separator)

Parameters
separator String

setPercentiles

public void setPercentiles ( percentiles)

Parameters
percentiles

storeTestMetrics

public void storeTestMetrics (TestDescription testDescription, 
                 testMetrics)

Used for storing the individual test metrics and use it for aggregation.

Parameters
testDescription TestDescription: contains the test details like class name and test name.

testMetrics : metrics collected for the test.

writeResultsToFile

public File writeResultsToFile (String testFileSuffix, 
                String testHeaderName, 
                 metrics, 
                File resultsFile)

Write metrics to a file.

Parameters
testFileSuffix String: is used as suffix in the test metric file name.

testHeaderName String: metrics will be written under the test header name.

metrics : to write in the file.

resultsFile File: if null create a new file and write the metrics otherwise append the test header name and metric to the file.

Returns
File file with the metric.