Skip to main content

pairbench: tells real benchmark differences from noise, with the verdicts FASTER, SLOWER, TIE, UNRESOLVED and NO VERDICT

PyPI version Python versions Licence: Apache-2.0 Documentation

Is one side really faster than another on this workload, on this machine, or is the difference noise?

Documentation · Quick start · How it decides · For AI agents · Showcases

A terminal recording with made-up values. pairbench plan prints the first lines of a plan for two command sides, new and old: the lineup with their twins, the positive control, sixteen rounds and the balance of the order. pairbench run then compares the two sides, reading the values a made-up benchmark prints through the lines driver, and ends on its verdict table: parse FASTER, encode TIE and resize SLOWER. The demo switches off the machine checks, so the footer under the table reads Machine state: unknown. The recording colours the verdict words; pairbench prints no colour.

Made-up values from a seeded generator; the session is docs/readme/demo/tape.sh.

pairbench runs both sides in paired, alternating rounds, measures the noise in the same rounds, and gives a verdict per case with its noise bar and an exact p-value.

pip install pairbench
pairbench run --side new=venv:.venv-new --side old=venv:.venv-old -- python bench.py

Two Python environments, one script, a verdict per case. More ways in Install and quick start and the headline command.

  • Paired, alternating rounds. Every side runs once per round, in an order that rotates and reverses, so no side keeps running before another.
  • A measured noise floor. Every side has a twin, an identical copy in the same rounds; the gap between them is the noise the verdict has to beat.
  • An exact test, corrected. An exact sign test per case, corrected for testing several cases at once.
  • A positive control. The baseline's workload twice in one start must read as twice the value, or every comparison of the run gets NO VERDICT.
  • Any side. A container image, a Python environment or any command, read by built-in drivers for common benchmark tools.
  • Built for agents. A skill, a tool server, JSON Schemas and exit codes that say what happened.

The headline command

pairbench run --side new=image:myorg/app:2.0 --side old=image:myorg/app:1.9 -- python bench.py

Example output (made-up numbers):

new against old (baseline)

case    new     old     change        noise  p        verdict
matmul  1.92 s  2.41 s  1.26x faster  ±1.8%  0.0010*  FASTER
fft     0.88 s  0.89 s  1.01x faster  ±2.1%  1.0*     TIE

Exact two-sided sign test over 16 paired rounds.
* corrected for testing 2 cases at once.
Rule: strict.
Machine state: quiet.
Baseline: old.
Positive control old~twice: ok.

FASTER needs two things at once: the gap is wider than the noise the run measured between each side and an identical copy of itself, and the direction is significant after the correction for testing several cases. TIE needs the same evidence the other way round. Anything else is UNRESOLVED or NO VERDICT, with the reason in plain words.

Four problems it solves

Problem What you get
Real or noise a verdict for every case, with the noise and the p-value beside it
Comparing whole environments container images, Python environments or any command, identified before and after
A busy shared machine wait for quiet, pin, lock, and set disturbed rounds aside
Numbers into documents every number of a report filled from a results file, and checked

Real or noise

One command gives a verdict for every case of a benchmark, with the noise and the p-value beside it. Here two Python environments run the same script, which prints its own timings:

pairbench run --side new=venv:.venv-new --side old=venv:.venv-old --driver lines -- python bench.py

Example output (made-up numbers):

case     new       old       change        noise  p        verdict
parse    0.310 s   0.402 s   1.30x faster  ±1.2%  0.0016*  FASTER
encode   1.020 s   1.010 s   1.01x slower  ±1.4%  0.21*    TIE
resize   0.555 s   0.571 s   1.03x faster  ±3.9%  0.0084*  UNRESOLVED (the difference is significant but lies inside the noise)

Comparing whole environments

A side can be a container image, a Python environment or any command. Before a run, pairbench plan prints what will run and checks that the sides are not the same thing:

pairbench plan --side pip=image:myorg/numpy-pip:1 --side conda=image:myorg/numpy-conda:1 -- python bench.py
Example output (made-up identities, shortened)
# lineup: pip, pip~same, conda, conda~same
# positive control: conda~twice, last in every round at position 5
# rounds: requested auto, planned 16
# launches: 82 (16 rounds of 5, and 2 warm-up launches)
# balance pip / conda: pip first in 8, conda first in 8, positions differ by 0 in sum
# verdict: reachable; 13 of 16 rounds must agree for one primary case when none tie (a tie is not counted)
# side pip: identified (image_id=sha256:aaaa..., digests=sha256:bbbb...)
# side conda: identified (image_id=sha256:cccc..., digests=sha256:dddd...)

Each side is identified before the run and again after it; two sides with the same identity are refused, and so is a side whose identity changed during the run.

A busy shared machine

On a machine other people use, pairbench can wait for quiet, pin the workload to a CPU set, take a lock, and watch every launch for load that is not the run's own:

pairbench run --side new=cmd:./bench-new --side old=cmd:./bench-old --cpus 4-7 --wait-quiet --lock /tmp/bench.lock

Example footer (made-up numbers):

Machine state: busy.
Without disturbed rounds 3, 11, matmul (new against old): 0.80x FASTER, agrees.

A round is set aside by a witness that never looks at the timings, and the analysis is repeated without it. Setting rounds aside can only downgrade a verdict, never create one.

Numbers into documents

Every number in a report can come from a results file instead of being typed by hand. A template holds tokens such as {{fig:matmul.new_vs_old.ratio}}, and:

pairbench fill report.in.md --results results.json -o report.md

writes the document with each token replaced by its figure, for example 0.80x (a made-up value). A missing figure stops the command with exit code 7 and lists every missing key. --check proves in an automated pipeline that a document still matches its results.

Install and quick start

pip install pairbench
pairbench doctor
pairbench selftest

doctor says what this machine supports and which external tools it found. selftest runs the known answers and controls of the statistics. Then print a plan, and run it:

pairbench plan --side new=venv:.venv-new --side old=venv:.venv-old -- python bench.py
pairbench run  --side new=venv:.venv-new --side old=venv:.venv-old -- python bench.py

The quick start walks through a first run and what each part of the output means.

Optional extras

The core imports only the Python standard library. Optional extras add what some features need:

Extra Adds
pairbench[plot] draws charts
pairbench[mcp] adds the tool server for AI agents
pairbench[gpu] reads GPU power
pairbench[llm] installs load tools for serving sides
pairbench[micro] installs a benchmark tool for the pytest-benchmark driver
pip install "pairbench[plot,mcp]"

Container images run under docker or podman, which you install yourself; the install page lists every external program.

How it decides

Eight rounds of one plan for two sides, new and old. Each round runs new, its twin new~same, old, its twin old~same, and the positive control old~twice, in an order that rotates and reverses from round to round, with the positive control last.

One plan for two sides, as pairbench plan prints it. The twins measure the noise in the same rounds as the comparison.

  1. Every side runs once per round, in an order that rotates and reverses from round to round, so no side keeps running before another (paired rounds).
  2. Every side has a twin, an identical copy in the same rounds, and the gap between them is the measured noise floor (noise floor).
  3. The values of a side and the baseline are paired round by round, and their ratio per round is summarised by its median.
  4. An exact sign test counts the rounds in which the subject was lower and those in which it was higher (sign test).
  5. The p-values are corrected for testing several cases at once (multiple comparisons).
  6. A verdict needs a gap wider than the sum of both noise floors and a significant direction; a tie needs the opposite, and everything else says why it has no verdict (verdicts).

The rule strict, for a case where lower is better:

Gap wider than the noise bar Gap inside the noise bar
Direction significant FASTER or SLOWER UNRESOLVED: significant, but inside the noise
Direction not significant UNRESOLVED: outside the noise, but not significant TIE

A case that cannot be graded, for example because the positive control failed or a side has no twin, reads NO VERDICT with its reason.

The verdict chart of a run with made-up values, as pairbench run draws it with the plot extra: for each case, the median ratio of new to old as a dot on a log scale centred at 1, with the noise band around 1. parse lies left of the band and reads FASTER, encode sits inside it and reads TIE, resize lies right of it and reads SLOWER.

The verdict chart of the run in the recording, made-up values, as the plot extra draws it: a verdict needs the dot outside the band and a significant direction.

What a run tells you besides the verdict

  • The positive control. One more entry in every round runs the baseline's workload twice in one start. It must read as twice the value. If it does not, something other than the work is inside the measurement, and every comparison of the run gets NO VERDICT (positive control).
  • The cost of a launch. For command and Python environment sides, every run times an empty command through the same launch path and reports it, with a note on any timed value that the cost could noticeably move (launch cost).
  • The diagnostics. After the measured rounds, each side is launched again under instruments, untimed: resource figures, counters and sampled stacks, with findings that describe a difference and never name a cause (diagnostics).
  • The charts and the report page. With the plot extra a run draws its charts, and every run writes one self-contained report.html with the verdicts, the controls and the flame graphs.

Why pairbench is not written in native code

The figures for this section come from one run of tools/launch_cost.py on one c4a-standard-4 machine, kept as docs/figures/launch-cost/results.json.

  • Between the clock reads that start and stop a launch, pairbench does nothing it can avoid: it starts no sampler, writes no record and reads no output until the second read (how a launch is timed).
  • Every run measures the cost of a launch and reports it. On that machine an empty launch cost 0.000375 s in the median, with 5.55e-05 s between the first and third quartiles.
  • That cost is the same on every side. An image side is timed by the container engine, so the tool is outside its time altogether.
  • In a run, the start of a process and the workload dominate; the tool's own part is small beside them. The run's workload, a few lines of Python, took 0.0136 s in the median with the interpreter's default start-up and 0.0115 s without its site module, against 0.000375 s for an empty launch.
  • A core in pure Python on the standard library installs anywhere with no compiler, and is easy to read and to audit.
  • A native launcher can be added as a plug-in if a real case needs one.
How the run was made and kept

The script waits for a quiet machine on the host before the run starts; inside the container the run records only what its own checks can see from there. The launch-cost results are kept without their sidecar because the results hide the two side commands; the commands are the constants of tools/launch_cost.py, so a reader runs that script to repeat the run rather than recomputing the hashes.

The tools it launches and reads

pairbench does not replace benchmark tools. It launches them, one launch per side per round, and reads what they produce. Each has a guide:

Driver Reads
wall the run time of each launch
lines ::pairbench:: lines a workload prints
gbench Google Benchmark JSON output
nvbench NVBench JSON output
pytest-benchmark pytest-benchmark JSON output
hyperfine hyperfine JSON output
perf perf stat counters
llama-bench llama-bench JSON output
guidellm GuideLLM reports for a serving side
aiperf AIPerf reports for a serving side
vllm-bench vllm bench serve results for a serving side

Container images run under docker or podman. perf, and GPU profilers you have installed yourself, can be called for counters, sampled stacks and profiles; pairbench does not include, download or redistribute any of them. See THIRD_PARTY_NOTICES.md.

Showcases

Each showcase is a folder with a config, a one-command run.sh, images pinned by digest and its workload. No approved result is published for any of them yet.

Showcase Compares
numpy-pip-vs-conda NumPy from pip against NumPy from conda
noisy-neighbour one image against itself, quiet and beside a load generator
pipeline-slowdown-check two revisions of a small library, as a check in a pipeline
python-versions two Python versions
inference-server-versions two versions of an inference server
gpu-kernel a GPU kernel in two CUDA development images
vendor-container-vs-pip a vendor framework container against a pip install

For AI agents

Entry point What it is
For AI agents the loop, the exit codes and how to report a result
llms.txt a short map of the documentation
skills/pairbench a skill, installed with pairbench skill install --dir PATH
pairbench mcp a tool server over standard input and output, with the mcp extra (tool server reference)
pairbench schema results the JSON Schema of the results; programs read comparisons[].outcome and comparisons[].reason

A client that reads an MCP settings file starts the tool server with:

{"mcpServers": {"pairbench": {"command": "pairbench", "args": ["mcp"]}}}

How it relates to other tools

Most of these pieces exist in other tools. pairbench combines paired alternating rounds, a measured same-against-same noise floor, an exact sign test and a correction for testing several cases, with container images as first-class sides and built-in readers for several benchmark tools. If you know a tool that does the same, tell us.

The comparison page describes other tools by what their own documentation says, with a link and the version read.

Limits

  • One baseline: every side is compared with it, not every side with every other.
  • One machine: sides alternate on one host; there is no launcher for cluster schedulers yet.
  • Energy is GPU energy only; CPU and wall-socket power are not measured.
  • An endpoint that is already running cannot be a side.
  • Linux and macOS; no Windows.
  • No history of results over time, and no re-running of a published results file on another machine.
  • A verdict holds for the machine, the load and the rounds it was measured on.
  • A serving experiment runs few rounds by default; the note below says how often that catches a real difference.
How often 8 rounds catch a real difference in a serving experiment

A serving round is long, so the default round count is small: --rounds auto gives 8 rounds for a serving experiment, and 8 rounds miss many small real differences. With a board of 4 primary metrics and the new side truly slower by twice the noise, 8 rounds give SLOWER for only about a third of the metrics (33 to 39 percent on the error-rate page); 16 rounds, with --rounds 16, give it for about 85 percent (83 to 88 percent). A difference of four times the noise is caught at 8 rounds 92 to 98 percent of the time. A miss at 8 rounds reads UNRESOLVED or TIE, not a wrong verdict. Verdicts in the wrong direction across the 162 settings of that page with a real difference: none in the simulated experiments. With no real difference, the largest share of experiments with any verdict is 1.3 percent, under the rule's alpha of 5 percent.

Cite, licence, contributing, security


pairbench is made by Eugo

Metadata

Release files for pairbench 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pairbench 0.2.1
File Size Uploaded Provenance Actions
pairbench-0.2.1.tar.gz 633.3 kB With provenance Details for pairbench-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pairbench 0.2.1
File Interpreter ABI Platform Actions
pairbench-0.2.1-py3-none-any.whl Python 3 none any Details for pairbench-0.2.1-py3-none-any.whl

Total release size: 1.3 MB

Release files / pairbench-0.2.1.tar.gz

Download URL pairbench-0.2.1.tar.gz
Size 633.3 kB
Tags Source
SHA-256 checksum
How to use checksums
52419ac5fcd2975aec91d3db9f6d7f0f45c65dbf1a1cee37403c35d2586a456b
BLAKE2b-256 checksum
How to use checksums
5d24b37d7ea78bc4074b583bb86c055b7f3e01fcd0b4908e08c3a95334cece55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / pairbench-0.2.1-py3-none-any.whl

Download URL pairbench-0.2.1-py3-none-any.whl
Size 706.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
488a32ef282926a1993e698fb626ea6c6b87773eed723444bd600a2cfe264220
BLAKE2b-256 checksum
How to use checksums
b39e3d71f9029cd4e89e952e01c2f990591c51a490f665525d5762c717ce09ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Security for pairbench 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pairbench-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page