# FrameMetricsAggregator

# FrameMetricsAggregator

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/app/FrameMetricsAggregator.java+class:androidx.core.app.FrameMetricsAggregator)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/app/FrameMetricsAggregator "View this page in Java")

<br />

```
class FrameMetricsAggregator
```

<br />

*** ** * ** ***

This class can be used to record and return data about per-frame durations. It returns those results in an array per metric type, with the results indicating how many samples were recorded for each duration value. The details of the durations data are described in[getMetrics](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#getMetrics()).

For more information on the various metrics tracked, see the documentation for the[FrameMetrics](https://developer.android.com/reference/android/view/FrameMetrics.html)API added in API 24 as well as the[GPU Profiling guide](https://developer.android.com/studio/profile/dev-options-rendering.html).

## Summary

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [ANIMATION_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#ANIMATION_DURATION())` = 256` A flag indicating that the metrics should track the animation duration.                                                                                                                                   |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [ANIMATION_INDEX](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#ANIMATION_INDEX())` = 8` The index in the metrics array where the data for[ANIMATION_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#ANIMATION_DURATION())is stored.                     |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [COMMAND_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#COMMAND_DURATION())` = 32` A flag indicating that the metrics should track the command duration.                                                                                                                                          |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [COMMAND_INDEX](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#COMMAND_INDEX())` = 5` The index in the metrics array where the data for[SYNC_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#SYNC_DURATION())is stored.                                   |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DELAY_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#DELAY_DURATION())` = 128` A flag indicating that the metrics should track the delay duration.                                                                                                                                               |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DELAY_INDEX](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#DELAY_INDEX())` = 7` The index in the metrics array where the data for[DELAY_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#DELAY_DURATION())is stored.                                     |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DRAW_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#DRAW_DURATION())` = 8` A flag indicating that the metrics should track the draw duration.                                                                                                                                                    |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DRAW_INDEX](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#DRAW_INDEX())` = 3` The index in the metrics array where the data for[DRAW_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#DRAW_DURATION())is stored.                                         |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [EVERY_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#EVERY_DURATION())` = 511` A flag indicating that the metrics should track all durations.                                                                                                                                                    |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [INPUT_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#INPUT_DURATION())` = 2` A flag indicating that the metrics should track the input duration.                                                                                                                                                 |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [INPUT_INDEX](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#INPUT_INDEX())` = 1` The index in the metrics array where the data for[INPUT_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#INPUT_DURATION())is stored.                                     |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [LAYOUT_MEASURE_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#LAYOUT_MEASURE_DURATION())` = 4` A flag indicating that the metrics should track the layout duration.                                                                                                                              |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [LAYOUT_MEASURE_INDEX](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#LAYOUT_MEASURE_INDEX())` = 2` The index in the metrics array where the data for[LAYOUT_MEASURE_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#LAYOUT_MEASURE_DURATION())is stored. |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SWAP_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#SWAP_DURATION())` = 64` A flag indicating that the metrics should track the swap duration.                                                                                                                                                   |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SWAP_INDEX](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#SWAP_INDEX())` = 6` The index in the metrics array where the data for[COMMAND_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#COMMAND_DURATION())is stored.                                   |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SYNC_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#SYNC_DURATION())` = 16` A flag indicating that the metrics should track the sync duration.                                                                                                                                                   |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SYNC_INDEX](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#SYNC_INDEX())` = 4` The index in the metrics array where the data for[SYNC_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#SYNC_DURATION())is stored.                                         |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [TOTAL_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#TOTAL_DURATION())` = 1` A flag indicating that the metrics should track the total duration.                                                                                                                                                 |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [TOTAL_INDEX](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#TOTAL_INDEX())` = 0` The index in the metrics array where the data for[TOTAL_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#TOTAL_DURATION())is stored.                                     |

|                                                                                                                                                                                                                                                                                       ### Public constructors                                                                                                                                                                                                                                                                                        |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [FrameMetricsAggregator](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#FrameMetricsAggregator())`()` Constructs a FrameMetricsAggregator object that will track[TOTAL_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#TOTAL_DURATION())metrics.                                                                                                                                                                                                                                                          |
| [FrameMetricsAggregator](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#FrameMetricsAggregator(int))`(metricTypeFlags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Constructs a FrameMetricsAggregator object that will track the metrics specified bty`metricTypeFlags`, which is a value derived by OR'ing together metrics constants such as[TOTAL_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#TOTAL_DURATION())to specify all metrics that should be tracked. |

|                                                                               ### Public functions                                                                                |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                     | [add](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#add(android.app.Activity))`(activity: `[Activity](https://developer.android.com/reference/android/app/Activity.html)`)` Starts recording frame metrics for the given activity.                               |
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[SparseIntArray](https://developer.android.com/reference/android/util/SparseIntArray.html)`!>?` | [getMetrics](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#getMetrics())`()` Returns the currently-collected metrics in an array of SparseIntArray objects.                                                                                                      |
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[SparseIntArray](https://developer.android.com/reference/android/util/SparseIntArray.html)`!>?` | [remove](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#remove(android.app.Activity))`(activity: `[Activity](https://developer.android.com/reference/android/app/Activity.html)`)` Stops recording metrics for`activity`and returns the collected metrics so far. |
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[SparseIntArray](https://developer.android.com/reference/android/util/SparseIntArray.html)`!>?` | [reset](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#reset())`()` Resets the metrics data and returns the currently-collected metrics.                                                                                                                          |
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[SparseIntArray](https://developer.android.com/reference/android/util/SparseIntArray.html)`!>?` | [stop](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#stop())`()` Stops recording metrics for all Activities currently being tracked.                                                                                                                             |

## Constants

### ANIMATION_DURATION

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

```
const val ANIMATION_DURATION = 256: Int
```

A flag indicating that the metrics should track the animation duration. This flag may be OR'd with the other flags here when calling[FrameMetricsAggregator](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#FrameMetricsAggregator(int))to indicate all of the metrics that should be tracked for that activity.  

### ANIMATION_INDEX

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

```
const val ANIMATION_INDEX = 8: Int
```

The index in the metrics array where the data for[ANIMATION_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#ANIMATION_DURATION())is stored.  

|                                                      See also                                                      |
|--------------------------------------------------------------------------------------------------------------------|---|
| [getMetrics](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#getMetrics()) |   |

### COMMAND_DURATION

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

```
const val COMMAND_DURATION = 32: Int
```

A flag indicating that the metrics should track the command duration. This flag may be OR'd with the other flags here when calling[FrameMetricsAggregator](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#FrameMetricsAggregator(int))to indicate all of the metrics that should be tracked for that activity.  

### COMMAND_INDEX

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

```
const val COMMAND_INDEX = 5: Int
```

The index in the metrics array where the data for[SYNC_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#SYNC_DURATION())is stored.  

|                                                      See also                                                      |
|--------------------------------------------------------------------------------------------------------------------|---|
| [getMetrics](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#getMetrics()) |   |

### DELAY_DURATION

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

```
const val DELAY_DURATION = 128: Int
```

A flag indicating that the metrics should track the delay duration. This flag may be OR'd with the other flags here when calling[FrameMetricsAggregator](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#FrameMetricsAggregator(int))to indicate all of the metrics that should be tracked for that activity.  

### DELAY_INDEX

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

```
const val DELAY_INDEX = 7: Int
```

The index in the metrics array where the data for[DELAY_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#DELAY_DURATION())is stored.  

|                                                      See also                                                      |
|--------------------------------------------------------------------------------------------------------------------|---|
| [getMetrics](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#getMetrics()) |   |

### DRAW_DURATION

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

```
const val DRAW_DURATION = 8: Int
```

A flag indicating that the metrics should track the draw duration. This flag may be OR'd with the other flags here when calling[FrameMetricsAggregator](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#FrameMetricsAggregator(int))to indicate all of the metrics that should be tracked for that activity.  

### DRAW_INDEX

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

```
const val DRAW_INDEX = 3: Int
```

The index in the metrics array where the data for[DRAW_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#DRAW_DURATION())is stored.  

|                                                      See also                                                      |
|--------------------------------------------------------------------------------------------------------------------|---|
| [getMetrics](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#getMetrics()) |   |

### EVERY_DURATION

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

```
const val EVERY_DURATION = 511: Int
```

A flag indicating that the metrics should track all durations. This is a shorthand for OR'ing all of the duration flags. This flag may be OR'd with the other flags here when calling[FrameMetricsAggregator](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#FrameMetricsAggregator(int))to indicate the metrics that should be tracked for that activity.  

### INPUT_DURATION

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

```
const val INPUT_DURATION = 2: Int
```

A flag indicating that the metrics should track the input duration. This flag may be OR'd with the other flags here when calling[FrameMetricsAggregator](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#FrameMetricsAggregator(int))to indicate all of the metrics that should be tracked for that activity.  

### INPUT_INDEX

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

```
const val INPUT_INDEX = 1: Int
```

The index in the metrics array where the data for[INPUT_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#INPUT_DURATION())is stored.  

|                                                      See also                                                      |
|--------------------------------------------------------------------------------------------------------------------|---|
| [getMetrics](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#getMetrics()) |   |

### LAYOUT_MEASURE_DURATION

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

```
const val LAYOUT_MEASURE_DURATION = 4: Int
```

A flag indicating that the metrics should track the layout duration. This flag may be OR'd with the other flags here when calling[FrameMetricsAggregator](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#FrameMetricsAggregator(int))to indicate all of the metrics that should be tracked for that activity.  

### LAYOUT_MEASURE_INDEX

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

```
const val LAYOUT_MEASURE_INDEX = 2: Int
```

The index in the metrics array where the data for[LAYOUT_MEASURE_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#LAYOUT_MEASURE_DURATION())is stored.  

|                                                      See also                                                      |
|--------------------------------------------------------------------------------------------------------------------|---|
| [getMetrics](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#getMetrics()) |   |

### SWAP_DURATION

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

```
const val SWAP_DURATION = 64: Int
```

A flag indicating that the metrics should track the swap duration. This flag may be OR'd with the other flags here when calling[FrameMetricsAggregator](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#FrameMetricsAggregator(int))to indicate all of the metrics that should be tracked for that activity.  

### SWAP_INDEX

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

```
const val SWAP_INDEX = 6: Int
```

The index in the metrics array where the data for[COMMAND_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#COMMAND_DURATION())is stored.  

|                                                      See also                                                      |
|--------------------------------------------------------------------------------------------------------------------|---|
| [getMetrics](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#getMetrics()) |   |

### SYNC_DURATION

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

```
const val SYNC_DURATION = 16: Int
```

A flag indicating that the metrics should track the sync duration. This flag may be OR'd with the other flags here when calling[FrameMetricsAggregator](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#FrameMetricsAggregator(int))to indicate all of the metrics that should be tracked for that activity.  

### SYNC_INDEX

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

```
const val SYNC_INDEX = 4: Int
```

The index in the metrics array where the data for[SYNC_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#SYNC_DURATION())is stored.  

|                                                      See also                                                      |
|--------------------------------------------------------------------------------------------------------------------|---|
| [getMetrics](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#getMetrics()) |   |

### TOTAL_DURATION

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

```
const val TOTAL_DURATION = 1: Int
```

A flag indicating that the metrics should track the total duration. This flag may be OR'd with the other flags here when calling[FrameMetricsAggregator](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#FrameMetricsAggregator(int))to indicate all of the metrics that should be tracked for that activity.  

### TOTAL_INDEX

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

```
const val TOTAL_INDEX = 0: Int
```

The index in the metrics array where the data for[TOTAL_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#TOTAL_DURATION())is stored.  

|                                                      See also                                                      |
|--------------------------------------------------------------------------------------------------------------------|---|
| [getMetrics](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#getMetrics()) |   |

## Public constructors

### FrameMetricsAggregator

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

```
FrameMetricsAggregator()
```

Constructs a FrameMetricsAggregator object that will track[TOTAL_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#TOTAL_DURATION())metrics. If more fine-grained metrics are needed, use[FrameMetricsAggregator](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#FrameMetricsAggregator(int))instead.  

### FrameMetricsAggregator

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

```
FrameMetricsAggregator(metricTypeFlags: Int)
```

Constructs a FrameMetricsAggregator object that will track the metrics specified bty`metricTypeFlags`, which is a value derived by OR'ing together metrics constants such as[TOTAL_DURATION](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#TOTAL_DURATION())to specify all metrics that should be tracked. For example,`TOTAL_DURATION | DRAW_DURATION`will track both the total and draw durations for every frame.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| `metricTypeFlags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | A bitwise collection of flags indicating which metrics should be recorded. |

## Public functions

### add

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

```
fun add(activity: Activity): Unit
```

Starts recording frame metrics for the given activity.  

|                                        Parameters                                         |
|-------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| `activity: `[Activity](https://developer.android.com/reference/android/app/Activity.html) | The Activity object which will have its metrics measured. |

### getMetrics

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

```
fun getMetrics(): Array<SparseIntArray!>?
```

Returns the currently-collected metrics in an array of SparseIntArray objects. The index of the array indicates which metric's data is stored in that SparseIntArray object. For example, results for total duration will be in the`[TOTAL_INDEX]`item.

The return value may be null if no metrics were tracked. This is especially true on releases earlier than API 24, as the FrameMetrics system does not exist on these earlier release. If the return value is not null, any of the objects at a given index in the array may still be null, which indicates that data was not being tracked for that type of metric. For example, if the FrameMetricsAggregator was created with a call to`new FrameMetricsAggregator(TOTAL_DURATION | DRAW_DURATION)`, then the SparseIntArray at index`INPUT_INDEX`will be null.

For a given non-null SparseIntArray, the results stored are the number of samples at each millisecond value (rounded). For example, if a data sample consisted of total durations of 5.1ms, 5.8ms, 6.1ms, and 8.2ms, the SparseIntArray at`[TOTAL_DURATION]`would have key-value pairs (5, 1), (6, 2), (8, 1).  

|                                                                                      Returns                                                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[SparseIntArray](https://developer.android.com/reference/android/util/SparseIntArray.html)`!>?` | An array whose index refers to the type of metric stored in that item's SparseIntArray object, e.g., data for`TOTAL_DURATION`is stored in the`[TOTAL_INDEX]`item. |

### remove

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

```
fun remove(activity: Activity): Array<SparseIntArray!>?
```

Stops recording metrics for`activity`and returns the collected metrics so far. Recording will continue if there are still other activities being tracked. Calling remove() does not reset the metrics array; you must call[reset](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#reset())to clear the data.  

|                                        Parameters                                         |
|-------------------------------------------------------------------------------------------|--------------------------------------------|
| `activity: `[Activity](https://developer.android.com/reference/android/app/Activity.html) | The Activity to stop tracking metrics for. |

|                                                                                      Returns                                                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[SparseIntArray](https://developer.android.com/reference/android/util/SparseIntArray.html)`!>?` | An array whose index refers to the type of metric stored in that item's SparseIntArray object, e.g., data for`TOTAL_DURATION`is stored in the`[TOTAL_INDEX]`item. |

|                                                      See also                                                      |
|--------------------------------------------------------------------------------------------------------------------|---|
| [getMetrics](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#getMetrics()) |   |

### reset

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

```
fun reset(): Array<SparseIntArray!>?
```

Resets the metrics data and returns the currently-collected metrics.  

|                                                                                      Returns                                                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[SparseIntArray](https://developer.android.com/reference/android/util/SparseIntArray.html)`!>?` | An array whose index refers to the type of metric stored in that item's SparseIntArray object, e.g., data for`TOTAL_DURATION`is stored in the`[TOTAL_INDEX]`item. |

|                                                      See also                                                      |
|--------------------------------------------------------------------------------------------------------------------|---|
| [getMetrics](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#getMetrics()) |   |

### stop

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

```
fun stop(): Array<SparseIntArray!>?
```

Stops recording metrics for all Activities currently being tracked. Like[remove](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#remove(android.app.Activity)), this method returns the currently-collected metrics. Calling stop() does not reset the metrics array; you must call[reset](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#reset())to clear the data.  

|                                                                                      Returns                                                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[SparseIntArray](https://developer.android.com/reference/android/util/SparseIntArray.html)`!>?` | An array whose index refers to the type of metric stored in that item's SparseIntArray object, e.g., data for`TOTAL_DURATION`is stored in the`[TOTAL_INDEX]`item. |

|                                                            See also                                                            |
|--------------------------------------------------------------------------------------------------------------------------------|---|
| [remove](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#remove(android.app.Activity)) |   |
| [getMetrics](https://developer.android.com/reference/kotlin/androidx/core/app/FrameMetricsAggregator#getMetrics())             |   |