Metrics

  
Track and report various runtime metrics for your application
Latest Update Stable Release Release Candidate Beta Release Alpha Release
January 10, 2024 - - 1.0.0-beta01 -

Declaring dependencies

To add a dependency on Metrics, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

Groovy

dependencies {
    implementation "androidx.metrics:metrics-performance:1.0.0-beta01"
}

Kotlin

dependencies {
    implementation("androidx.metrics:metrics-performance:1.0.0-beta01")
}

For more information about dependencies, see Add build dependencies.

Feedback

Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.

Create a new issue

See the Issue Tracker documentation for more information.

Version 1.0.0

Version 1.0.0-beta01

January 10, 2024

The API and functionality of this library has been stable for some time. This release simply pushes the library to beta.

androidx.metrics:metrics-performance:1.0.0-beta01 is released. Version 1.0.0-beta01 contains these commits.

Version 1.0.0-alpha04

April 5, 2023

This release updates JankStats to the latest fixes, which include more accurate and comprehensive timing information.

androidx.metrics:metrics-performance:1.0.0-alpha04 is released. Version 1.0.0-alpha04 contains these commits.

API Changes

  • cpuDuration now more accurate, also new totalDuration on API31 (I59ce8, b/243694893)

Version 1.0.0-alpha03

July 27, 2022

androidx.metrics:metrics-performance:1.0.0-alpha03 is released. Version 1.0.0-alpha03 contains these commits.

  • This release contains minor API refinements as the library gets closer to beta. One of the API changes removes the Executor from the createAndTrack() factory method for creating a JankStats object. This has implications for the OnFrameListener callback, as that listener is now called on the thread which delivers the per-frame data to JankStats (the Main/UI thread on versions earlier than API 24, and the FrameMetrics thread on API 24+). Moreover, the FrameData object passed to the listener is now reused every frame, so data from that object must be copied and cached elsewhere during the callback, as that object should be considered obsolete as soon as the listener returns.

  • There were also various bug fixes, including some concurrency issues.

  • Finally, the fix to reuse FrameData (mentioned above) means that there are now zero allocations per frame due to frame metrics delivery. There weren’t many allocations before, but the new approach means that you can use JankStats without incurring any per-frame GC overhead in your app.

API Changes

  • Updated method and parameter names in PerformanceMetricsState to make the results of those calls clearer. (I56da5, b/233421985)
  • Added benchmark tests to track allocations, eliminated some internal allocations related to state management and reporting. Note that FrameData passed to listeners is now considered volatile; that structure will be reused for the next frame and the data is only reliable until the listener returns.
  • Removed Executor from constructor for JankStats; listeners are now called on whatever thread the internal data was received upon. (I12743)

Bug Fixes

  • Fixed crash due to double-removal of OnFrameMetricsAvailableListener (I44094, b/239457413)
  • Return to original logic of posting OnPreDrawListener messages at front of queue, for more consistent and predictable frame timing. (I05a43, b/233358407)
  • Fixed ConcurrentModificationException bug where the list of listener delegates was being modified while it was also being iterated through to send per-frame data. (Ib7693, b/236612357)

Version 1.0.0-alpha02

June 29, 2022

androidx.metrics:metrics-performance:1.0.0-alpha02 is released. Version 1.0.0-alpha02 contains these commits.

API Changes

Bug Fixes

Version 1.0.0-alpha01

February 9, 2022

androidx.metrics:metrics-performance:1.0.0-alpha01 is released. Version 1.0.0-alpha01 contains these commits.

New Features

  • The JankStats library provides functionality to instrument and receive callbacks in your application at runtime which can help find real world performance problems.
  • JankStats combines an API that makes it easy to inject information about UI state with capabilities for tracking and reporting per-frame performance to allow developers to understand not whether an application has performance issues, but when and why.