How-to guide
Run suites in browsers
Measure the same suites in Chromium, Firefox and WebKit, next to Node, with @ac-bench/browser's runtimes.
Before you start. A suite that runs with
measure -c bench.config.tsin Node.
Install the runtimes and the browser builds
@ac-bench/browser drives the browsers through Playwright. playwright-core
is a peer dependency, and the browser builds are installed separately:
npm install --save-dev @ac-bench/browser playwright-corenpx playwright-core install chromium firefox webkit
List them in the config
Each runtime is a plugin. Listing it configures it; it does not select it.
import { chromium, firefox, webkit } from "@ac-bench/browser";
import { defineConfig } from "@ac-bench/cli";
import durationPlugin from "@ac-bench/measure-duration/plugin";
export default defineConfig({
plugins: [durationPlugin, chromium(), firefox(), webkit()],
});Check that they launch
measure runtimes prints, for Node and every runtime the config lists, what it
found, and each problem with its remedy:
npx measure runtimes -c bench.config.tsA browser build that does not match the installed playwright-core is the
usual problem: install it again with npx playwright-core install firefox, or
point the runtime’s executablePath at another build.
Select them for a run
--runtime (repeatable) selects runtimes for one run, in order; the config’s
runtimes key does it for every run. Without either, a run measures in Node
only.
npx measure -c bench.config.ts --runtime node --runtime chromium --runtime firefox--headed shows the browsers, for debugging; the archive records it.
Keep the suite portable
A suite a page runs imports no node: module. The bundler refuses a file that
reaches one and names the chain (a.bench.ts → node:assert); that file alone
fails to load in that runtime. Use assertSameResult from @ac-bench/util
for equivalence checks, and the runtime’s bundle.alias to substitute a module
a suite cannot avoid.
What each measure supports in each engine:
| measure | Chromium | Firefox | WebKit |
|---|---|---|---|
| duration, in-process | ✓ | ✓ | ✓ |
| duration, spawned processes | — | — | — |
| resource, allocated and retained bytes | ✓ heap growth of performance.memory |
— | — |
| resource, CPU time, collections | — | — | — |
| jitter, constant-time | — | — | — |
A measure a runtime does not support is skipped there without a launch, and its gates read not-applicable.
Variations
Two Chromiums
Two runtimes of one engine need distinct ids, which --runtime and baselines
use. For example, a WebGPU Chromium beside the default one:
chromium({ id: "chromium-gpu", channel: "chromium", args: ["--enable-unsafe-webgpu"] })A faster, shared browser
isolation: "context" keeps one browser per runtime and gives each execution a
fresh context: faster, with a separate renderer process guaranteed in Chromium
only. The default, "browser", starts a new browser for every execution. See
How a gate decides.
A missing system library
measure runtimes names the library. On Fedora, WebKit needs Ubuntu’s ICU 74
and libjpeg 8, given through the runtime’s env.LD_LIBRARY_PATH.