Most visited

Recently visited

Added in API level 24

FrameMetrics

public final class FrameMetrics
extends Object

java.lang.Object
   ↳ android.view.FrameMetrics


Class containing timing data for various milestones in a frame lifecycle reported by the rendering subsystem.

Supported metrics can be queried via their corresponding identifier.

Summary

Constants

int ANIMATION_DURATION

Metric identifier for animation callback duration.

int COMMAND_ISSUE_DURATION

Metric identifier for command issue duration.

int DRAW_DURATION

Metric identifier for draw duration.

int FIRST_DRAW_FRAME

Metric identifier for a boolean value determining whether this frame was the first to draw in a new Window layout.

int INPUT_HANDLING_DURATION

Metric identifier for input handling duration.

int LAYOUT_MEASURE_DURATION

Metric identifier for layout/measure duration.

int SWAP_BUFFERS_DURATION

Metric identifier for swap buffers duration.

int SYNC_DURATION

Metric identifier for sync duration.

int TOTAL_DURATION

Metric identifier for total frame duration.

int UNKNOWN_DELAY_DURATION

Metric identifier for unknown delay.

Public constructors

FrameMetrics(FrameMetrics other)

Constructs a FrameMetrics object as a copy.

Public methods

long getMetric(int id)

Retrieves the value associated with Metric identifier id for this frame.

Inherited methods

From class java.lang.Object

Constants

ANIMATION_DURATION

Added in API level 24
int ANIMATION_DURATION

Metric identifier for animation callback duration.

Represents the number of nanoseconds elapsed issuing animation callbacks.

Constant Value: 2 (0x00000002)

COMMAND_ISSUE_DURATION

Added in API level 24
int COMMAND_ISSUE_DURATION

Metric identifier for command issue duration.

Represents the number of nanoseconds elapsed issuing draw commands to the GPU.

Constant Value: 6 (0x00000006)

DRAW_DURATION

Added in API level 24
int DRAW_DURATION

Metric identifier for draw duration.

Represents the number of nanoseconds elapsed computing DisplayLists for transformations applied to the view hierarchy.

Constant Value: 4 (0x00000004)

FIRST_DRAW_FRAME

Added in API level 24
int FIRST_DRAW_FRAME

Metric identifier for a boolean value determining whether this frame was the first to draw in a new Window layout.

getMetric(int) will return 0 for false, 1 for true.

First draw frames are expected to be slow and should usually be exempt from display jank calculations as they do not cause skips in animations and are usually hidden by window animations or other tricks.

Constant Value: 9 (0x00000009)

INPUT_HANDLING_DURATION

Added in API level 24
int INPUT_HANDLING_DURATION

Metric identifier for input handling duration.

Represents the number of nanoseconds elapsed issuing input handling callbacks.

Constant Value: 1 (0x00000001)

LAYOUT_MEASURE_DURATION

Added in API level 24
int LAYOUT_MEASURE_DURATION

Metric identifier for layout/measure duration.

Represents the number of nanoseconds elapsed measuring and laying out the invalidated pieces of the view hierarchy.

Constant Value: 3 (0x00000003)

SWAP_BUFFERS_DURATION

Added in API level 24
int SWAP_BUFFERS_DURATION

Metric identifier for swap buffers duration.

Represents the number of nanoseconds elapsed issuing the frame buffer for this frame to the display subsystem.

Constant Value: 7 (0x00000007)

SYNC_DURATION

Added in API level 24
int SYNC_DURATION

Metric identifier for sync duration.

Represents the number of nanoseconds elapsed synchronizing the computed display lists with the render thread.

Constant Value: 5 (0x00000005)

TOTAL_DURATION

Added in API level 24
int TOTAL_DURATION

Metric identifier for total frame duration.

Represents the total time in nanoseconds this frame took to render and be issued to the display subsystem.

Equal to the sum of the values of all other time-valued metric identifiers.

Constant Value: 8 (0x00000008)

UNKNOWN_DELAY_DURATION

Added in API level 24
int UNKNOWN_DELAY_DURATION

Metric identifier for unknown delay.

Represents the number of nanoseconds elapsed waiting for the UI thread to become responsive and process the frame. This should be 0 most of the time.

Constant Value: 0 (0x00000000)

Public constructors

FrameMetrics

Added in API level 24
FrameMetrics (FrameMetrics other)

Constructs a FrameMetrics object as a copy.

Use this method to copy out metrics reported by onFrameMetricsAvailable(Window, FrameMetrics, int)

Parameters
other FrameMetrics: the FrameMetrics object to copy.

Public methods

getMetric

Added in API level 24
long getMetric (int id)

Retrieves the value associated with Metric identifier id for this frame.

Boolean metrics are represented in [0,1], with 0 corresponding to false, and 1 corresponding to true.

Parameters
id int: the metric to retrieve
Returns
long the value of the metric or -1 if it is not available.

Hooray!