Skip to content

Benchmarking

The benchmark script compares the TypeScript engine (check), the Rust engine run directly, and the check-native CLI, each with Node.js and Bun. It runs from a source checkout of the tools-monorepo.

Compile the TypeScript, build the release engine, and run the script:

Terminal window
pnpm nx run repopo:build:compile
cargo build --release --manifest-path packages/repopo/crates/core/Cargo.toml
./packages/repopo/benchmark.sh --quick
./packages/repopo/benchmark.sh --json /tmp/repopo-benchmark.json

The benchmark needs Node.js and the release binary. Bun is optional, and Hyperfine is not used.

OptionDescription
--quickOne warmup round and three timed rounds instead of the defaults, three and ten.
--warmup NNumber of warmup rounds.
--runs NNumber of timed rounds.
--scenario NAMERun only this scenario. Repeat to select several.
--json PATHWrite the results as JSON.

Each round runs every case once, in shuffled order, to reduce ordering bias. Every command must exit successfully: a policy violation or runtime error stops the benchmark and prints diagnostics. No fixes are applied. Native cases use the release binary explicitly, and all stdin cases share one snapshot of the Git file list.

ScenarioWorkload
startupTop-level help: CLI and binary startup with no policy check
emptyEmpty config and empty stdin: check initialization and sidecar startup
inventory-stdinEmpty config with the file snapshot: input parsing and file routing
inventory-gitEmpty config, with Git listing the files instead of stdin
configTwenty synthetic policies with empty stdin: policy setup without file matching
matchingThe same policies and snapshot, with no matches: matching without handlers
noopTwenty policies that match every path and return true: dispatch and no-op handlers
real-stdinThe repository’s own config with the snapshot
real-gitA normal check with the repository’s config, with Git listing the files

The JSON output includes machine and runtime metadata, the commands and inputs, and raw samples with their round and order. It also has the median, mean, standard deviation, quartiles, and range in milliseconds.

Useful comparisons:

  • inventory-git vs. inventory-stdin: the cost of listing files with Git.
  • config vs. empty: setting up synthetic policies.
  • noop vs. matching: successful matching, dispatch, and handler overhead.
  • (matching − config) vs. (inventory-stdin − empty): matching overhead beyond basic routing.
  • Each cli-* case vs. its core-* counterpart: the overhead of the CLI wrapper.

These comparisons isolate workloads but don’t time individual phases exclusively. They include interactions, serialization, and scheduling noise. Repository policies still list and check the full inventory in real-stdin. The real workloads include config imports, file I/O, and policy-specific work. Results reflect warm filesystem caches, not a cold-cache run.