Documentation Index
Fetch the complete documentation index at: https://codspeed.io/docs/llms.txt
Use this file to discover all available pages before exploring further.
The
@codspeed/playwright-plugin integration currently supports only the
walltime instrument. CPU Simulation is not available.@codspeed/playwright-plugin
is the CodSpeed integration for Playwright. It runs a
user-defined flow against a target application, measures the time spent inside
that flow, and reports it to CodSpeed. The flow itself is plain Playwright code,
so anything Playwright can drive can be benchmarked.
Today the plugin supports Electron apps as a
target. Browser-based targets (existing dev servers, static builds, hosted URLs)
are on the roadmap and will be added under the same
bench API.Installation
Install the plugin alongsideplaywright:
Example usage with Electron
Build your Electron app first so the main entrypoint exists (e.g.,out/main/index.js), then declare a benchmark with target.kind set to
"electron":
bench/inbox.bench.ts
beforeRound, measures fn, runs
afterRound, then closes the app.
For a more complete example, have a look at the
example benchmark
included in the codspeed-node repository.
API
The plugin exposes a singlebench function. Its shape is target-agnostic:
Identifier of the benchmark, used by CodSpeed to track it across runs.
The function whose execution time is measured. Receives a Playwright
Page bound to the target.
Everything that runs inside fn counts toward the reported timing.Target configuration and benchmark settings, detailed below.
Options
Discriminated union describing what to drive. The
kind field selects the
target; the remaining fields are specific to that kind. Current variants:
{ kind: "electron", ... }. More will be added
without breaking existing call sites.Number of measurement rounds. Can be overridden at runtime via the
CODSPEED_ROUNDS environment variable.Runs before each round, after the target is ready. Use it to bring the app to
a ready state. Not measured.
Runs after each round, before the target is torn down. Not measured.
Electron target options
Selects the Electron target.
Absolute path to the Electron main entrypoint, e.g.,
out/main/index.js.Extra CLI flags forwarded to the Electron process.
Working directory for the Electron process. Also the directory
electron is
resolved from when target.electronExecutablePath is not set.Absolute path to the Electron binary. Only set this to override the default
resolution.
Running the benchmarks locally
With node 24+, you can run typescript files directly:terminal
bench runs the app and prints per-round timings to the terminal.
Results are uploaded to CodSpeed only when running in the
CI environment or when using the
CodSpeed CLI.
Running the benchmarks in your CI
To generate performance reports, you need to run the benchmarks in your CI. This allows CodSpeed to automatically run benchmarks and warn you about regressions during development. Here is an example of a GitHub Actions workflow that runs the benchmarks and reports the results to CodSpeed on every push to themain branch and every
pull request: