Metric.Measurement


@ExperimentalMetricApi
public final class Metric.Measurement


Represents a Metric's measurement of a single iteration.

To validate results in tests, use assertEqualMeasurements

Summary

Public constructors

Measurement(@NonNull String name, double data)

Represents a measurement with a single value captured per iteration.

Measurement(@NonNull String name, @NonNull List<@NonNull Double> dataSamples)

Represents a measurement with a value sampled an arbitrary number of times per iteration.

Public methods

final @NonNull List<@NonNull Double>

Measurement values captured by the metric, length constraints defined by requireSingleValue.

final @NonNull String

Unique name of the metric, should be camel case with abbreviated suffix, e.g. startTimeNs

final boolean

True if the data param is a single value per measurement, false if it contains an arbitrary number of samples.

Public constructors

Measurement

Added in 1.2.0
public Measurement(@NonNull String name, double data)

Represents a measurement with a single value captured per iteration.

For example, in a startup Macrobenchmark, StartupTimingMetric returns a single measurement for timeToInitialDisplayMs.

Measurement

Added in 1.2.0
public Measurement(@NonNull String name, @NonNull List<@NonNull Double> dataSamples)

Represents a measurement with a value sampled an arbitrary number of times per iteration.

For example, in a jank Macrobenchmark, FrameTimingMetric can return multiple measurements for frameOverrunMs - one for each observed frame.

When measurements are merged across multiple iterations, percentiles are extracted from the total pool of samples: P50, P90, P95, and P99.

Public methods

getData

Added in 1.2.0
public final @NonNull List<@NonNull DoublegetData()

Measurement values captured by the metric, length constraints defined by requireSingleValue.

getName

Added in 1.2.0
public final @NonNull String getName()

Unique name of the metric, should be camel case with abbreviated suffix, e.g. startTimeNs

getRequireSingleValue

Added in 1.2.0
public final boolean getRequireSingleValue()

True if the data param is a single value per measurement, false if it contains an arbitrary number of samples.