Skip to content

chore: add a self-contained benchmark harness - #123

Merged
mcollina merged 1 commit into
masterfrom
chore/benchmark-harness
Oct 18, 2026
Merged

mcollina merged 1 commit into
masterfrom
chore/benchmark-harness

Conversation

@mcollina

Copy link
Copy Markdown
Owner

Adds a self-contained, reproducible throughput benchmark harness under benchmarks/, plus the optional comparison libraries, npm scripts, and docs.

What's included

  • benchmarks/bench.js — head-to-head encode/decode vs msgpackr, msgpack-lite, @msgpack/msgpack, and JSON, across the generated datasets. Each function runs under a fixed wall-clock budget (default 4000 ms, override BENCH_MS), reports ops/sec and ratios relative to msgpack5, and verifies every round-trip against the source JSON. Missing comparison libraries are skipped.
  • benchmarks/stream.js — streaming .decoder() throughput vs msgpackr's UnpackrStream.
  • benchmarks/ab.js — A/B harness comparing two local msgpack5 checkouts via AB_OLD/AB_NEW (interleaved rounds, median ops/sec, new/old ratio).
  • benchmarks/gen-data.js — deterministic generator for the datasets (sample-large, example4, example5, mixed), written to the git-ignored benchmarks/data/.
  • benchmarks/data/ is git-ignored (generated on demand by gen-data.js/bench.js).
  • Comparison libraries added as devDependencies; npm run bench, bench:stream, bench:ab, bench:gen scripts; README "Benchmarks" section; AGENTS.md updated (decoder description and benchmark commands).

The existing benchmarks/encodedecode.js/parseshortmap.js are left as-is.

Notes

  • benchmarks/ is linted by standard as part of npm test; the new scripts follow the existing project style. All 4391 tests still pass on Node 22/24/26.
  • The A/B harness (bench:ab) just points AB_OLD/AB_NEW at two checkouts, so it works with any two local builds (no sandbox/symlink setup required).
  • msgpackr's msgpackr-extract is an optional native dependency; if it can't be built, msgpackr still loads (pure-JS fallback) and the harness keeps working.

@mcollina
mcollina merged commit 9646551 into master Oct 18, 2026
20 checks passed
@mcollina
mcollina deleted the chore/benchmark-harness branch October 18, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant