TimeCapture


@ExperimentalBenchmarkConfigApi
class TimeCapture : MetricCapture


Time metric, which reports time in nanos, based on the time passed to captureStop.

Reports elapsed time with the label from name, which defaults to timeNs.

Summary

Public constructors

Public functions

open Unit

Pause data collection.

open Unit

Resume data collection

open Unit
captureStart(timeNs: Long)

Starts collecting data for a run.

open Unit
captureStop(timeNs: Long, output: LongArray, offset: Int)

Mark the end of a run, and store offset metrics in the output array, per sub metric.

Inherited functions

From androidx.benchmark.MetricCapture
open operator Boolean
equals(other: Any?)
open Int

Inherited properties

From androidx.benchmark.MetricCapture
List<String>

List of names of metrics produced by this MetricCapture.

Public constructors

TimeCapture

Added in 1.3.0-alpha03
TimeCapture(name: String = "timeNs")
Parameters
name: String = "timeNs"

Metric name of the measured time, defaults to timeNs.

Public functions

capturePaused

Added in 1.3.0-alpha03
open fun capturePaused(): Unit

Pause data collection.

captureResumed

Added in 1.3.0-alpha03
open fun captureResumed(): Unit

Resume data collection

captureStart

Added in 1.3.0-alpha03
open fun captureStart(timeNs: Long): Unit

Starts collecting data for a run.

Called at the start of each run.

Parameters
timeNs: Long

Current time, just before starting metrics. Can be used directly to drive a timing metric produced.

captureStop

Added in 1.3.0-alpha03
open fun captureStop(timeNs: Long, output: LongArray, offset: Int): Unit

Mark the end of a run, and store offset metrics in the output array, per sub metric.

To output values, store them in the output array offset by both the parameter offset, and their submetric index, for example:

class MyMetricCapture("firstSubMetricName", "secondSubMetricName") {
//...
override fun captureStop(timeNs: Long, output: LongArray, offset: Int) {
output[offset + 0] = firstSubMetricValue
output[offset + 1] = secondSubMetricValue
}
}
Parameters
timeNs: Long

Time of metric capture start, in monotonic time (java.lang.System.nanoTime)

output: LongArray

LongArray sized to hold all simultaneous sub metric outputs, use offset as the initial position in output to start writing submetrics.

offset: Int

Offset into the output array to start writing sub metrics.