Benchmarks are the best way to compare different Android phones. They help you decide which phone is better for your needs, and they provide a concrete number so you can make an informed decision.
Benchmark scores come from extensive testing of each phone’s performance in areas like CPU, GPU, RAM management, web browser speed, among others.
This post will give you a quick introduction to what benchmarks are and how they work – it’ll also explain why benchmark scores are helpful when deciding which smartphone suits your lifestyle best.
In simplest terms, a benchmark provides a means for testing how your application performs on Android devices. It is a tool you can use to help analyze and debug performance issues and ensure that no relapses are occurring when updates are introduced.
Benchmarking helps identify the fastest performing device on the market by running standardized tests that measure both hardware performance as well as software optimization under controlled conditions.
The goal is to compare similarly priced devices with similar specs side-by-side. Android offers two benchmark libraries that are useful in analyzing and assessing different kinds of problems in your application. These are the benchmark library and Macrobenchmark library.
- The Benchmark Library: The jetpack benchmark library enables you to benchmark either Kotlin based or Java-based application codes within Android Studio. The library handles warmup, estimates your code performance and allocation counts, and produces your benchmarking results. The benchmark library only reports data about your application and not about the system overall. This property is best suited for assessing the performance of problems specific to the app and not the ones that might relate to widespread problems involving the system.
- The Macrobenchmark Library: Macrobenchmark measures more extensive end-user interactions. These interactions include startup, scrolling, and animations. Unlike the benchmark library, Macrobenchmark injects events and monitors outcomes externally from a test application that you provide. Macrobenchmark provides direct control over the performance environment being tested. As part of the results, the Macrobenchmark comes up with trace files that you can look at in the Android Studio to identify performance issues to analyze and debug.
Benchmarking is great at helping you find operations that require optimization and can also help figure out why certain operations are slow by showing you what is going on while they are running. They are mostly used for CPU work that runs multiple times within your app. These include data processing and conversions, scrolling, and pieces of code that are run continually.
Some codes are not easy to benchmark. This is because benchmarks run in a loop, and any code that is not running continually or performs differently when called many times may not be recommended for benchmarking. For these types of code, it is better to use tracing or profiling of the code in your app instead.
Note that this doesn’t mean that you cannot benchmark codes in your startup path, but rather it means that you should pick code that’s run in a loop and likely to get JIT-compiled.