FrameMetricsAggregator
open class FrameMetricsAggregator
kotlin.Any | |
↳ | androidx.core.app.FrameMetricsAggregator |
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()
.
For more information on the various metrics tracked, see the documentation for the FrameMetrics API added in API 24 as well as the GPU Profiling guide.
Summary
Constants | |
---|---|
static Int |
A flag indicating that the metrics should track the animation duration. |
static Int |
The index in the metrics array where the data for |
static Int |
A flag indicating that the metrics should track the command duration. |
static Int |
The index in the metrics array where the data for |
static Int |
A flag indicating that the metrics should track the delay duration. |
static Int |
The index in the metrics array where the data for |
static Int |
A flag indicating that the metrics should track the draw duration. |
static Int |
The index in the metrics array where the data for |
static Int |
A flag indicating that the metrics should track all durations. |
static Int |
A flag indicating that the metrics should track the input duration. |
static Int |
The index in the metrics array where the data for |
static Int |
A flag indicating that the metrics should track the layout duration. |
static Int |
The index in the metrics array where the data for |
static Int |
A flag indicating that the metrics should track the swap duration. |
static Int |
The index in the metrics array where the data for |
static Int |
A flag indicating that the metrics should track the sync duration. |
static Int |
The index in the metrics array where the data for |
static Int |
A flag indicating that the metrics should track the total duration. |
static Int |
The index in the metrics array where the data for |
Public constructors | |
---|---|
<init>() Constructs a FrameMetricsAggregator object that will track |
|
Constructs a FrameMetricsAggregator object that will track the metrics specified bty |
Public methods | |
---|---|
open Unit |
Starts recording frame metrics for the given activity. |
open Array<SparseIntArray!>? |
Returns the currently-collected metrics in an array of SparseIntArray objects. |
open Array<SparseIntArray!>? |
Stops recording metrics for |
open Array<SparseIntArray!>? |
reset() Resets the metrics data and returns the currently-collected metrics. |
open Array<SparseIntArray!>? |
stop() Stops recording metrics for all Activities currently being tracked. |
Constants
ANIMATION_DURATION
static val ANIMATION_DURATION: 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(int)
to indicate all of the metrics that should be tracked for that activity.
Value: 1 << ANIMATION_INDEX
ANIMATION_INDEX
static val ANIMATION_INDEX: Int
The index in the metrics array where the data for ANIMATION_DURATION
is stored.
Value: 8
See Also
COMMAND_DURATION
static val COMMAND_DURATION: 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(int)
to indicate all of the metrics that should be tracked for that activity.
Value: 1 << COMMAND_INDEX
COMMAND_INDEX
static val COMMAND_INDEX: Int
The index in the metrics array where the data for SYNC_DURATION
is stored.
Value: 5
See Also
DELAY_DURATION
static val DELAY_DURATION: 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(int)
to indicate all of the metrics that should be tracked for that activity.
Value: 1 << DELAY_INDEX
DELAY_INDEX
static val DELAY_INDEX: Int
The index in the metrics array where the data for DELAY_DURATION
is stored.
Value: 7
See Also
DRAW_DURATION
static val DRAW_DURATION: 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(int)
to indicate all of the metrics that should be tracked for that activity.
Value: 1 << DRAW_INDEX
DRAW_INDEX
static val DRAW_INDEX: Int
The index in the metrics array where the data for DRAW_DURATION
is stored.
Value: 3
See Also
EVERY_DURATION
static val EVERY_DURATION: 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(int)
to indicate the metrics that should be tracked for that activity.
Value: 0x1ff
INPUT_DURATION
static val INPUT_DURATION: 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(int)
to indicate all of the metrics that should be tracked for that activity.
Value: 1 << INPUT_INDEX
INPUT_INDEX
static val INPUT_INDEX: Int
The index in the metrics array where the data for INPUT_DURATION
is stored.
Value: 1
See Also
LAYOUT_MEASURE_DURATION
static val LAYOUT_MEASURE_DURATION: 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(int)
to indicate all of the metrics that should be tracked for that activity.
Value: 1 << LAYOUT_MEASURE_INDEX
LAYOUT_MEASURE_INDEX
static val LAYOUT_MEASURE_INDEX: Int
The index in the metrics array where the data for LAYOUT_MEASURE_DURATION
is stored.
Value: 2
See Also
SWAP_DURATION
static val SWAP_DURATION: 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(int)
to indicate all of the metrics that should be tracked for that activity.
Value: 1 << SWAP_INDEX
SWAP_INDEX
static val SWAP_INDEX: Int
The index in the metrics array where the data for COMMAND_DURATION
is stored.
Value: 6
See Also
SYNC_DURATION
static val SYNC_DURATION: 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(int)
to indicate all of the metrics that should be tracked for that activity.
Value: 1 << SYNC_INDEX
SYNC_INDEX
static val SYNC_INDEX: Int
The index in the metrics array where the data for SYNC_DURATION
is stored.
Value: 4
See Also
TOTAL_DURATION
static val TOTAL_DURATION: 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(int)
to indicate all of the metrics that should be tracked for that activity.
Value: 1 << TOTAL_INDEX
TOTAL_INDEX
static val TOTAL_INDEX: Int
The index in the metrics array where the data for TOTAL_DURATION
is stored.
Value: 0
See Also
Public constructors
<init>
FrameMetricsAggregator()
Constructs a FrameMetricsAggregator object that will track TOTAL_DURATION
metrics. If more fine-grained metrics are needed, use FrameMetricsAggregator(int)
instead.
<init>
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
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: A bitwise collection of flags indicating which metrics should be recorded. |
Public methods
add
open fun add(@NonNull activity: Activity): Unit
Starts recording frame metrics for the given activity.
Parameters | |
---|---|
activity |
Activity: The Activity object which will have its metrics measured. |
getMetrics
@Nullable open 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).
Return | |
---|---|
Array<SparseIntArray!>? |
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. |