Stay organized with collections
Save and categorize content based on your preferences.
RelativeFrameTimeHistogram
open class RelativeFrameTimeHistogram
A histogram of frame times relative to their deadline. This class aids in reporting AppJankStats
to the system and is designed for use by library widgets. It facilitates the recording of frame times in relation to the frame deadline. The class records the distribution of time remaining until a frame is considered janky or how janky the frame was.
A frame's relative frame time value indicates whether it was delivered early, on time, or late. A negative relative frame time value indicates the frame was delivered early, a value of zero indicates the frame was delivered on time and a positive value indicates the frame was delivered late. The values of the endpoints indicate how early or late a frame was delivered.
The relative frame times are recorded as a histogram: values are added
to a bucket by increasing the bucket's counter. The count of frames with a relative frame time between bucket endpoints
i
and i+1
can be obtained through index i
of getBucketCounters
.
Summary
Public constructors |
Create a new instance of RelativeFrameTimeHistogram.
|
Public methods |
open Unit |
Increases the count by one for the bucket representing the relative frame time.
|
open IntArray |
Returns the counts for the all the relative frame time buckets.
|
open IntArray |
Returns the relative frame time endpoints for the histogram.
|
Public constructors
RelativeFrameTimeHistogram
RelativeFrameTimeHistogram()
Create a new instance of RelativeFrameTimeHistogram.
Public methods
addRelativeFrameTimeMillis
open fun addRelativeFrameTimeMillis(frameTimeMillis: Int): Unit
Increases the count by one for the bucket representing the relative frame time.
Parameters |
frameTimeMillis |
Int: relative frame time in millis, relative frame time is the difference between a frames deadline and when it was rendered. |
getBucketCounters
open fun getBucketCounters(): IntArray
Returns the counts for the all the relative frame time buckets.
Return |
IntArray |
an array of integers representing the counts of relative frame times. This value cannot be null. |
getBucketEndpointsMillis
open fun getBucketEndpointsMillis(): IntArray
Returns the relative frame time endpoints for the histogram.
Index i
of getBucketCounters
contains the count of frames that had a relative frame time between endpoints[i]
(inclusive) and endpoints[i+1]
(exclusive).
Return |
IntArray |
array of integers representing the endpoints for the predefined histogram count buckets. This value cannot be null. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-03-13 UTC.
[null,null,["Last updated 2025-03-13 UTC."],[],[],null,["# RelativeFrameTimeHistogram\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nRelativeFrameTimeHistogram\n==========================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/app/jank/RelativeFrameTimeHistogram \"View this page in Java\") \n\n```\nopen class RelativeFrameTimeHistogram\n```\n\n|---|--------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.app.jank.RelativeFrameTimeHistogram](#) |\n\nA histogram of frame times relative to their deadline. This class aids in reporting [AppJankStats](/reference/kotlin/android/app/jank/AppJankStats) to the system and is designed for use by library widgets. It facilitates the recording of frame times in relation to the frame deadline. The class records the distribution of time remaining until a frame is considered janky or how janky the frame was.\n\nA frame's relative frame time value indicates whether it was delivered early, on time, or late. A negative relative frame time value indicates the frame was delivered early, a value of zero indicates the frame was delivered on time and a positive value indicates the frame was delivered late. The values of the endpoints indicate how early or late a frame was delivered.\n\nThe relative frame times are recorded as a histogram: values are [added](#addRelativeFrameTimeMillis(kotlin.Int)) to a bucket by increasing the bucket's counter. The count of frames with a relative frame time between [bucket endpoints](#getBucketEndpointsMillis()) `i` and `i+1` can be obtained through index `i` of [getBucketCounters](#getBucketCounters()).\n\nSummary\n-------\n\n| Public constructors ||\n|----------------------------------------------------------------------------------------------------------------------|---|\n| [RelativeFrameTimeHistogram](#RelativeFrameTimeHistogram())`()` Create a new instance of RelativeFrameTimeHistogram. |\n\n| Public methods ||\n|--------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [addRelativeFrameTimeMillis](#addRelativeFrameTimeMillis(kotlin.Int))`(`frameTimeMillis:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Increases the count by one for the bucket representing the relative frame time. |\n| open [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html) | [getBucketCounters](#getBucketCounters())`()` Returns the counts for the all the relative frame time buckets. |\n| open [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html) | [getBucketEndpointsMillis](#getBucketEndpointsMillis())`()` Returns the relative frame time endpoints for the histogram. |\n\nPublic constructors\n-------------------\n\n### RelativeFrameTimeHistogram\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nRelativeFrameTimeHistogram()\n```\n\nCreate a new instance of RelativeFrameTimeHistogram.\n\nPublic methods\n--------------\n\n### addRelativeFrameTimeMillis\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun addRelativeFrameTimeMillis(frameTimeMillis: Int): Unit\n```\n\nIncreases the count by one for the bucket representing the relative frame time.\n\n| Parameters ||\n|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `frameTimeMillis` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): relative frame time in millis, relative frame time is the difference between a frames deadline and when it was rendered. |\n\n### getBucketCounters\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getBucketCounters(): IntArray\n```\n\nReturns the counts for the all the relative frame time buckets.\n\n| Return ||\n|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|\n| [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html) | an array of integers representing the counts of relative frame times. This value cannot be null. |\n\n### getBucketEndpointsMillis\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getBucketEndpointsMillis(): IntArray\n```\n\nReturns the relative frame time endpoints for the histogram.\n\nIndex `i` of [getBucketCounters](#getBucketCounters()) contains the count of frames that had a relative frame time between `endpoints[i]` (inclusive) and `endpoints[i+1]` (exclusive).\n\n| Return ||\n|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|\n| [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html) | array of integers representing the endpoints for the predefined histogram count buckets. This value cannot be null. |"]]