# FrameTimingMetric

Artifact: [androidx.benchmark:benchmark-macro](https://developer.android.com/jetpack/androidx/releases/benchmark) [View Source](https://cs.android.com/search?q=file:androidx/benchmark/macro/Metric.kt+class:androidx.benchmark.macro.FrameTimingMetric) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/benchmark#1.1.0)

*** ** * ** ***


```
class FrameTimingMetric : Metric
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.benchmark.macro.Metric](https://developer.android.com/reference/kotlin/androidx/benchmark/macro/Metric) ||
|   | ↳ | [androidx.benchmark.macro.FrameTimingMetric](https://developer.android.com/reference/kotlin/androidx/benchmark/macro/FrameTimingMetric) |

*** ** * ** ***

Metric which captures timing information from frames produced by a benchmark, such as a scrolling or animation benchmark.

This outputs the following measurements:

- `frameOverrunMs` (Requires API 31) - How much time a given frame missed its deadline by. Positive numbers indicate a dropped frame and visible jank / stutter, negative numbers indicate how much faster than the deadline a frame was.

- `frameDurationCpuMs` - How much time the frame took to be produced on the CPU - on both the UI Thread, and RenderThread. Note that this doesn't account for time before the frame started (before Choreographer#doFrame), as that data isn't available in traces prior to API 31.

- `frameCount` - How many total frames were produced. This is a secondary metric which can be used to understand *why* the above metrics changed. For example, when removing unneeded frames that were incorrectly invalidated to save power, `frameOverrunMs` and `frameDurationCpuMs` will often get worse, as the removed frames were trivial. Checking `frameCount` can be a useful indicator in such cases.

Generally, prefer tracking and detecting regressions with `frameOverrunMs` when it is available, as it is the more complete data, and accounts for modern devices (including higher, variable framerate rendering) more naturally.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/benchmark/macro/FrameTimingMetric#FrameTimingMetric()()` |
| `@https://developer.android.com/reference/kotlin/androidx/benchmark/macro/ExperimentalMetricApi https://developer.android.com/reference/kotlin/androidx/benchmark/macro/FrameTimingMetric#FrameTimingMetric(kotlin.String,kotlin.String)(processNameSuffix: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, metricNameSuffix: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` |

## Public constructors

### FrameTimingMetric

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/benchmark#1.1.0)

```
FrameTimingMetric()
```

### FrameTimingMetric

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/benchmark#1.4.0)

```
@ExperimentalMetricApi
FrameTimingMetric(
    processNameSuffix: String,
    metricNameSuffix: String = processNameSuffix.replace(oldValue = ":", newValue = "_")
)
```

| Parameters |
|---|---|
| `processNameSuffix: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | A suffix appended to the app's package name for subprocesses. This is useful when there are separate subprocesses of the app. |
| `metricNameSuffix: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html = processNameSuffix.replace(oldValue = ":", newValue = "_")` | A suffix appended to the metric names. Use this to distinguish metrics collected from different subprocesses in the app. Defaults to `https://developer.android.com/reference/kotlin/androidx/benchmark/macro/FrameTimingMetric#(kotlin.String,kotlin.String)` with ":" replaced by "_". |