Skip to content

modestbench

A full-ass benchmarking framework for Node.js

Look, we like tinybench too. It’s great! But we got tired annoyed inspired after writing the same wrapper code around it for the quinqua­gintacent­illionth time. We have more homegrown wrappers than B-Real.

We wanted a benchmarking framework that didn’t make us think (because we are stupid). One that just worked—with sensible defaults, multiple output formats, historical tracking, and a built-in profiler to tell us what’s even worth benchmarking. Plug-and-f’ing-play, fam.

modestbench is what happens when you swaddle a minimal benchmarking library in scads of overengineered-but-useful features so you can focus on making your code fast. That’s we’re selling, anyway.

Fast & Accurate

Choose your poison: the peppy tinybench engine for quick iterations, or the accurate engine with V8 optimization guards when you really need statistical rigor. Who knows? You could!

Multiple Output Formats

Human-readable terminal output. JSON for your CI pipeline. CSV for your spreadsheets so you can make those sweet, sweet line graphs. Simultaneous.

Historical Tracking

Tracks every run automatically. Compare historical results. Detect performance regressions before they ship. Set a budget, even! You are now a Real Developer.

Profile & Discover

Don’t know what to benchmark? Run just whatever with V8’s built-in profiler and it’ll tell you exactly where the code’s hot. Do you really want to open a profile visualizer?

CLI & API

Powerful CLI with “sensible” defaults. Programmatic API for when you … have a use-case for this, I guess?

TypeScript Support

Fully type-safe. Write your benchmarks in JS or TS. CJS or ESM. No loader.

benchmarks/example.bench.js
export default {
'Array.push()': () => {
const arr = [];
for (let i = 0; i < 1000; i++) {
arr.push(i);
}
return arr;
},
'Array spread': () => {
let arr = [];
for (let i = 0; i < 1000; i++) {
arr = [...arr, i];
}
return arr;
},
};

Just export an object with functions and modestbench figures out the rest.

Terminal window
# Run all benchmarks (finds .bench.js files automatically)
modestbench
# We have lots of options; here are some
modestbench --iterations 5000 --reporter human --reporter json

Boom. Done. Results printed to your terminal, saved to JSON, and tracked in history. You’re welcome.

We built modestbench because we got tired of:

  • Writing the same wrapper code - tinybench is great but doesn’t handle discovery, configuration, or reporting
  • Guessing what to benchmark - We automated that shit
  • Tracking results manually - Automatic history with comparison tools so you can prove your optimizations worked
  • Writing our own reporters - Multiple options—optionally running simultaneously—because we can
  • One Two engines - Fast tinybench for development, accurate for when you need the receipts
  • Advanced statistics - IQR outlier removal, coefficient of variation, percentiles (statistics nerd stuff)
  • Organized benchmarks - Suite-based structure with setup/teardown hooks
  • Tag-based filtering - Run only the benchmarks you wanna run
  • Historical data - Automatic tracking with comparison tools
  • Built-in profiler - Find hot code paths with just a command

Whether you’re optimizing a hot loop, comparing algorithm implementations, or setting up performance regression testing in CI, modestbench might even work for you.