The Macrobenchmark library enables you to measure app performance, create baseline profiles and monitor whether changes to your app make a difference to app performance. The 1.2.0 will graduate to a beta release soon. Here are some feature highlights.
From Android 13 and newer you can generate a Baseline Profile with the
BaselineProfileRule on non-rooted devices or emulators.
From Android 14 and newer, target apps no longer need to be reinstalled between benchmark runs. This enables apps to save state, such as cache, session state or login tokens between runs. This change removes the need to inject these states manually before benchmarking, which would have required a rooted device.
✨ Baseline Profile generation is no longer considered experimental ✨
You can remove the opt-in to experimental API annotation from your code when creating a baseline profile using the
collectBaselineProfile method. But if you like to stay on experimental APIs, we have a new API for your consideration.
The newly introduced
collectStableBaselineProfile runs and waits until a profile is considered stable for a given amount of iterations. This means that your app’s Baseline Profile will better reflect what’s going on in your app as a code path is executed.
More powerful metrics with custom trace processing
PerfettoTraceRule enables custom trace collection in tests other than benchmarks (requires API 23+). This is a powerful feature that will allow users to collect performance and timing data about tests.
PerfettoTraceProcessor enables querying trace contents, and is the engine behind all of the existing Macrobenchmark Metric APIs. Now it’s possible to use it with
TraceMetric to define fully custom metrics in the same way Macrobenchmark does from anything information in a Perfetto system trace.. This is another powerful feature that will allow users to customize their benchmarks even further.
PowerMetric API can be used to measure energy consumption and power states. This is a useful feature that will allow users to track the energy consumption of their benchmarks.
The team behind Macrobenchmark also made a variety of other improvements to ergonomics, fixed bugs and improved overall behavior. To learn more, check out the documentation. If you want to get more detail, you can find a full list of release notes with attached code and tracking issues here.
Leave a Reply