CompilationMode

public class CompilationMode

Known direct subclasses
CompilationMode.Full

Full ahead-of-time compilation.

CompilationMode.None

No pre-compilation - entire app will be allowed to Just-In-Time compile as it runs.

CompilationMode.Partial

Partial ahead-of-time app compilation.


Type of compilation to use for a Macrobenchmark.

Every Macrobenchmark has compilation reset before running, so that previous runs do not interfere with the next. This compilation mode dictates any pre-compilation that occurs before repeatedly running the setup / measure blocks of the benchmark.

On Android N+ (API 24+), there are different levels of compilation supported:

  • Partial - the default configuration of Partial will partially pre-compile your application, if a Baseline Profile is included in your app. This represents the most realistic fresh-install experience on an end-user's device. You can additionally or instead use Partial.warmupIterations to use Profile Guided Optimization, using the benchmark content to guide pre-compilation to mimic an application's performance after some, and JIT-ing has occurred.

  • Full - the app is fully pre-compiled. This is generally not representative of real user experience, as apps are not fully pre-compiled on user devices, but this can be used to either illustrate ideal performance, or to reduce noise/inconsistency from just-in-time compilation while the benchmark runs.

  • None - the app isn't pre-compiled at all, bypassing the default compilation that should generally be done at install time, e.g. by the Play Store. This will illustrate worst case performance, and will show you performance of your app if you do not enable baseline profiles, useful for judging the performance impact of the baseline profiles included in your application.

On Android M (API 23), only Full is supported, as all apps are always fully compiled.

To understand more how these modes work, you can see comments for each class, and also see the Android Runtime compilation modes (which are passed by benchmark into cmd compile to compile the target app).

Summary

Nested types

CompilationMode.Companion
CompilationMode.Full

Full ahead-of-time compilation.

CompilationMode.None

No pre-compilation - entire app will be allowed to Just-In-Time compile as it runs.

CompilationMode.Partial

Partial ahead-of-time app compilation.