Register now for Android Dev Summit 2019!


The Benchmark library makes it easy to benchmark your Kotlin-based or Java-based code from within Android Studio. The library handles warmup, measures your code performance, and outputs benchmarking results to the Android Studio console.

For information on how to use the Benchmark library in your app or library, see Benchmark app code.

Declaring dependencies

To add a dependency on Benchmark, 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:


dependencies {

android {
  defaultConfig {
    testInstrumentationRunner "androidx.benchmark.AndroidBenchmarkRunner"

Version 1.0.0-alpha03

July 2, 2019

androidx.benchmark:benchmark:1.0.0-alpha03 and androidx.benchmark:benchmark-gradle-plugin:1.0.0-alpha03 are released. The commits included in this version can be found here.

New features

  • Expose sleep duration due to thermal throttling per benchmark in the full JSON report

Bug fixes

  • The Gradle plugin should no longer be required to be applied after Android plugins and the Android block
  • Adds support for benchmark reports on Android Q devices using scoped storage

Version 1.0.0-alpha02

June 6, 2019

androidx.benchmark:1.0.0-alpha02 and androidx.benchmark:benchmark-gradle-plugin:1.0.0-alpha02 are released. The commits included in this version can be found here.

Note that we are treating the JSON schema as an API. We plan to follow the same stability constraints as other APIs: stable (with very rare exceptions) once in beta, and fixed in final release, with only additions in minor releases and changes/removals in major releases.

API changes

  • Overhauled JSON schema. Further changes to the JSON schema are likely to be limited to additions:

    • Reorganized the result object structure to support additional metric groups in the future (b/132713021)
    • Added test run context information, such as device and build info and whether clocks are locked, to the top-level object (b/132711920)
    • Time metric names now have ‘ns’ in their name (b/132714527)
    • Additional stats added per reported metric (maximum, median, minimum), and removed simplified 'nanos' summary stat (b/132713851)
  • Removed XML output (b/132714414)

  • Thermal throttle detection removed from BenchmarkState.reportData API (b/132887006)

Bug fixes

  • Fixed ./gradlew lockClocks not sticking on some recent OS devices (b/133424037)
  • Throttling detection disabled for emulator (b/132880807)

Version 1.0.0-alpha01

May 7, 2019

androidx.benchmark:benchmark:1.0.0-alpha01 is released. The commits included in this version are available here.