Android Emulator Development, Anbox, & Waydroid

The Ultimate Android Emulator Performance Test Suite: Custom Scripts for CPU & GPU Benchmarking

Google AdSense Native Placement - Horizontal Top-Post banner

Introduction: Why Custom Emulator Benchmarking Matters

Android emulators, such as the official Android Studio Emulator, Anbox, and Waydroid, are indispensable tools for developers, testers, and power users. They allow Android applications to run on non-Android host systems, primarily Linux, providing flexibility and convenience. However, accurately assessing their performance can be challenging. Standard Android benchmarks, while useful for physical devices, often fail to capture the nuances of an emulated environment, including the overhead introduced by virtualization layers, graphics translation, and host system resource allocation. This article delves into building a custom test suite with shell scripts to thoroughly benchmark Android emulator CPU and GPU performance, providing actionable insights for optimization and comparison.

Understanding an emulator’s performance characteristics is crucial for several reasons:

  • Development Efficiency: Slower emulators mean longer compile-deploy-test cycles.
  • Application Compatibility: Identifying bottlenecks that might affect an app’s responsiveness or rendering.
  • System Optimization: Pinpointing areas where host system configurations or emulator settings can be tuned for better speed.
  • Comparative Analysis: Objectively comparing different emulator solutions (e.g., Anbox vs. Waydroid vs. traditional AVD).

Challenges in Emulator Benchmarking

Benchmarking an Android emulator isn’t as straightforward as running an app like AnTuTu or Geekbench. Here are some inherent challenges:

  • Virtualization Overhead: The CPU and memory virtualization layers inherently add latency and reduce raw throughput.
  • Graphics Abstraction: OpenGL ES calls from the guest (emulator) must be translated to the host’s native OpenGL/Vulkan, a process that can introduce significant performance penalties.
  • Host System Variability: Results are heavily influenced by the host’s CPU, GPU, RAM, storage speed, and even the kernel and display server (X11 vs. Wayland).
  • Limited Standard Tools: Many Android benchmark tools are designed for ARM-native execution and might not perform optimally or even run correctly in an x86/x64 emulated environment with different graphics drivers.

This necessitates a more granular approach, using tools and scripts that can isolate and test specific components.

CPU Benchmarking Strategies with Custom Scripts

To accurately measure CPU performance within an Android emulator, we need to execute compute-intensive tasks and measure their completion time. We’ll leverage command-line tools often available in minimal Android environments or easily installable.

1. Prime Number Calculation Test (Busybox / Shell)

This simple script calculates prime numbers, putting a sustained load on a single CPU core. We can iterate it to test multiple cores if supported by the emulator’s shell.

#!/system/bin/sh# CPU Benchmark: Prime Number Calculation Scriptecho "Starting CPU Prime Number Benchmark..."START_TIME=$(date +%s%N)MAX_NUMBER=100000 # Adjust for desired duration and difficultyfor ((i=2; i<=MAX_NUMBER; i++)); doIS_PRIME=1for ((j=2; j*j<=i; j++)); doif ((i % j == 0)); thenIS_PRIME=0breakfi;done# Optional: print primes to verify, but disable for performanceif ((IS_PRIME == 1)); then#echo "$i is prime"fi;doneEND_TIME=$(date +%s%N)ELAPSED_NS=$((END_TIME - START_TIME))ELAPSED_MS=$((ELAPSED_NS / 1000000))echo "Benchmark finished. Time elapsed: ${ELAPSED_MS} ms"

Execution Steps:

  1. Save the script as `cpu_benchmark.sh` inside the emulator (e.g., `/data/local/tmp/`).
  2. Grant execute permissions: `chmod +x /data/local/tmp/cpu_benchmark.sh`.
  3. Run the script: `/data/local/tmp/cpu_benchmark.sh`.
  4. For Android Studio Emulator or Waydroid, use `adb shell` to get a shell. For Anbox, you might need to use `anbox shell` or `anbox launch –shell`.

2. OpenSSL Speed Test (Cryptographic Operations)

OpenSSL provides a built-in `speed` command that can benchmark various cryptographic algorithms, which are CPU-intensive.

#!/system/bin/sh# CPU Benchmark: OpenSSL Speed Testecho "Starting OpenSSL AES-256-CBC Benchmark..."openssl speed -evp aes-256-cbc # You can choose other algorithms like sha256, rsa2048, etc.echo "OpenSSL AES-256-CBC Benchmark finished."

Execution Steps:

  1. Ensure `openssl` is available in your emulator environment. If not, you might need to install it via a package manager (if available) or push a static binary.
  2. Save the script as `ssl_benchmark.sh`.
  3. `chmod +x ssl_benchmark.sh`.
  4. Run: `./ssl_benchmark.sh`.

GPU Benchmarking Strategies

Benchmarking the GPU in an emulator primarily involves testing its ability to render OpenGL ES graphics efficiently. This is where the graphics translation layer’s performance becomes critical.

1. glmark2-es2 (OpenGL ES 2.0 Benchmark)

`glmark2-es2` is a popular benchmark tool for OpenGL ES 2.0. It runs a series of tests, including various scene renderings, texture operations, and lighting effects, providing a score and FPS for each test.

#!/system/bin/sh# GPU Benchmark: glmark2-es2 Testecho "Starting glmark2-es2 Benchmark..."glmark2-es2 # Or glmark2 for OpenGL, but ES2 is more relevant for Androidecho "glmark2-es2 Benchmark finished."

Installation and Execution for Waydroid/Anbox:

  1. Waydroid:
    • Enter the Waydroid container shell: `sudo waydroid shell`.
    • Update and install: `apt update && apt install glmark2-es2`.
    • Run: `glmark2-es2`.
  2. Anbox:
    • Enter the Anbox container shell: `sudo anbox shell`.
    • Update and install: `apt update && apt install glmark2-es2`.
    • Run: `glmark2-es2`.
  3. Android Studio Emulator: `glmark2-es2` is typically not pre-installed. You would need to compile it for ARM/x86 Android or find a pre-built binary and push it via `adb push`. This is often more complex for this specific emulator.

Interpreting Results: `glmark2-es2` provides a composite score and individual frame rates for various sub-tests. Higher scores and FPS indicate better GPU performance. Pay attention to tests like

Android Mobile Specs & Compare Directory

Are you researching mobile hardware properties, processor SoCs, GPU chipsets, or RAM configurations? Access our complete specs catalog to compare up to 5 devices side-by-side!

Compare Devices Specs →
Google AdSense Inline Placement - Content Footer banner