TraceMetricsRecorder

public class TraceMetricsRecorder
extends Object implements IMetricsRecorder

java.lang.Object
   ↳ com.android.tradefed.profiler.recorder.TraceMetricsRecorder


An IMetricsRecorder that records metrics taken from the /d/tracing directory. Metrics to be recorded need to be provided as TraceMetrics. The default descriptor has the format prefix:funcname:param[=expectedval]:metrictype.

Summary

Public constructors

TraceMetricsRecorder()

Public methods

BiFunction<Double, Double, Double> getMergeFunction(String key)

Returns a BiFunction describing how to aggregate results for a particular metric over the course of multiple test runs.

String getName()

Returns a name for this IMetricsRecorder.

Map<String, Double> parseTraceFile(File fullTrace)
void setUp(ITestDevice device, Collection<String> descriptors)

Sets up the recorder.

void startRecording()

Begin recording metrics.

Map<String, Double> stopRecordingAndReturnMetrics()

Stop recording metrics and return metrics recorded.

Protected methods

BufferedReader getReaderFromFile(File trace)

Public constructors

TraceMetricsRecorder

TraceMetricsRecorder ()

Public methods

getMergeFunction

BiFunction<Double, Double, Double> getMergeFunction (String key)

Returns a BiFunction describing how to aggregate results for a particular metric over the course of multiple test runs. Examples of relevant functions are average, sum, or count. The BiFunction is used as an argument to merge(K, V, BiFunction).

Parameters
key String: the name of the metric

Returns
BiFunction<Double, Double, Double> a BiFunction used to aggregate values of that metric

getName

String getName ()

Returns a name for this IMetricsRecorder.

Returns
String the name

parseTraceFile

Map<String, Double> parseTraceFile (File fullTrace)

Parameters
fullTrace File

Returns
Map<String, Double>

setUp

void setUp (ITestDevice device, 
                Collection<String> descriptors)

Sets up the recorder. After calling this method, the recorder is ready to begin. This method should be called by setUp(IInvocationContext).

Parameters
device ITestDevice: The device on which this recorder will monitor metrics.

descriptors Collection: A collection of strings describing what metrics to collect and by what means to collect them. It is up to individual implementers to decide how to interpret these string descriptors.

Throws
DeviceNotAvailableException

startRecording

void startRecording ()

Begin recording metrics. This should be called at the beginning of a single test.

Throws
DeviceNotAvailableException

stopRecordingAndReturnMetrics

Map<String, Double> stopRecordingAndReturnMetrics ()

Stop recording metrics and return metrics recorded. This should be called at the end of a single test.

Returns
Map<String, Double> a Map which contains all metrics recorded over the duration of the test.

Throws
DeviceNotAvailableException

Protected methods

getReaderFromFile

BufferedReader getReaderFromFile (File trace)

Parameters
trace File

Returns
BufferedReader

Throws
FileNotFoundException