Skip to content
This repository was archived by the owner on Nov 22, 2026. It is now read-only.

mojo-bench v0.1.0

Choose a tag to compare

@amarbarosys amarbarosys released this 04 Nov 14:18
· 12 commits to main since this release

mojo-bench v0.1.0

Released: 2026-11-04 · Commit: 6b3f6fb · Previous: first release

What it does

Benchmark harness for Mojo that reports statistics, not one number: warmup, auto iteration count,
median, MAD, min, p95, seeded 95% bootstrap CI, outlier count, and compare() that says
"no difference" when the CIs overlap. 211 lines, no dependency beyond the stdlib. Every statistic is
checked bit for bit against a Python reference (tools/oracle.py) on 3117 seeded cases.

A Mojo library for Linux (Mojo 1.2). Use it from source with mojo run -I path/to/mojo-bench/src app.mojo.

Highlights

  • One call gives median, MAD, min, p95, a 95% CI and an outlier count, not one number.
  • compare() says "no difference" when the CIs overlap, so a noisy 3% never reads as a win.
  • Statistics match a Python reference bit for bit; the bootstrap runs about 115x faster than that reference.

Changes

Added

  • bench, bench2 (interleaved samples), compare, stats, table, Result.json().

Verified

Check Result
scripts/check.sh: 3117 seeded cases (2514 stats, 603 compare) vs tools/oracle.py byte-identical, PASS
Negative control: tools/oracle.py --broken through the same diff differs, as it must
2x slower function (tests/behavior.mojo) reads 2.00x, CI about 1.99 to 2.01, "b faster"
Two copies of one function reads 1.00x, "no difference"
README and docs/api.md code blocks vs examples/*.mojo equal, compiled and run; drifted README fails the gate
scripts/bench.sh, stats 20x(n=200, B=1000) Mojo 14 to 15 ms, Python 1662 to 1721 ms, peak RSS 11 vs 12 MB
Memory every gate command under MemoryMax=4G; none hit the cap

Known limits

  • CPU timing only: no GPU sync, no hardware counters.
  • stats and compare need a non-empty vector.
  • The CI workflow (.github/workflows/ci.yml) has not run on GitHub: there is no remote. UNVERIFIED there.
  • Statistics are of the median; there is no mean or stddev.

Upgrade / run

mojo run -I path/to/mojo-bench/src app.mojo

Commits

  • 6b3f6fb docs: README, api, design, perf; doc blocks are compiled examples
  • 50c0e73 chore: license, notice, CI workflow
  • 9686f8e feat: benchmark harness with seeded bootstrap statistics and compare