tree: d1fbb7c82855d40aa47ac6b98eddb6e11a166f11 [search]
  1. examples/
  2. src/
  3. AndroidManifest.xml.jinja2
  4. BUILD.gn
  5. cdp_relay.cc
  6. OWNERS
  7. package_benchmarks.py
  8. README.md
tools/android/wpr_benchmark_runner/README.md

On-device WPR benchmark runner

An Android instrumentation APK that runs Web Page Replay (WPR) benchmarks on device without host orchestration. This is also useful for running benchmarks on emulators.

The examples folder contains LoadLine2, Speedometer 3.0, and JetStream 3.0 benchmark definitions. Users must provide their own assets or use existing assets in Crossbench.

GN argument

Set this in args.gn; each runner APK packages one benchmark definition.

# JSON definition to package; select any example or your own config.
wpr_benchmark_runner_benchmark_config =
    "//tools/android/wpr_benchmark_runner/examples/loadline2_phone.json"

Browser configuration

Set browser.package, browser.http_port, and browser.https_port in the JSON definition. Set browser.flags to an array of Chrome switches, including the replay certificate's SPKI allowlist. Replay routing is generated from these ports; do not supply --host-resolver-rules. The examples show these fields.

Run configuration

  • benchmark_name: Required benchmark identifier. Use loadline2-phone for LLP2 touch-triggered navigation.
  • actions_file: Crossbench-style JSON or HJSON containing pages, named blocks, and action arrays. Paths are relative to the runner JSON, or start with // for the Chromium source root.
  • probe: Set "enabled": true to start tracing before the page actions and stop afterward. trace_config selects the trace categories and buffer settings.
  • trace_processor: Set output to name the collected trace; processing actions refer to this name in their input fields. Set "enabled": true to build and package Perfetto's trace processor. Disabled when omitted or enabled is false. The trace_processor and process_llp2_trace actions require it; otherwise packaging fails. Trace collection is configured separately through probe.
  • output_processing: Actions executed after the page actions and trace collection, such as process_llp2_trace, js, and dump_to_syslog.
  • file_output: Set enabled and a files array of {input, filename} entries. Files are exported only when -e results-dir <directory> is supplied. Trace files are exported before output processing; result files afterward.

Actions

Each action sets action to a type below. Optional parameters show their defaults.

ActionRequired parametersOptional parametersDescription
geturltarget="_self", ready_state="interactive", url_contains=url, timeout="10s"Navigate in a new (_new_tab) or current (_self) tab. Wait for document readiness and the URL substring. ready_state accepts any, interactive, or complete. Create the first tab with _new_tab.
waitduration—Pause for the given duration.
tapposition: {"x": ..., "y": ...}—Inject an Android touch at display pixel coordinates.
jsscriptoutput (none), timeout="5s"Execute a JavaScript function body through CDP. Use return and output to store its result.
touch_navigationscripttimeout="5s"Run the JavaScript navigation script in response to an Android touch event.
wait_for_conditionconditionfailure_condition (none), timeout="10s", poll_interval_ms=100, command_timeout_ms=5000Poll a JavaScript body until it returns true; fail if the optional failure body returns true.
trace_processorinput, query_file, outputtimeout="120s"Run a SQL query on a completed trace and store one CSV result table. Cells remain strings.
process_llp2_traceinput, query_file, version, outputtimeout="120s"Query a completed trace and calculate LLP2 phone page metrics and the total score. version accepts 2 or 2.x, such as 2.5.0.
dump_to_sysloginput—Print a result to logcat under cr_WprBenchmark.

Run

Use an Android 14+ device and Chromium built with debuggable_apks = true.

From the device shell:

am instrument -w \
  org.chromium.wpr_benchmark_runner/org.chromium.wpr_benchmark_runner.WprBenchmarkInstrumentation