DEV Community

Mu Micro
Mu Micro

Posted on

Developers can't benchmark shell commands without Rust — so I built `bench-run`

The problem

Developers have no easy way to benchmark how long a shell command takes across multiple runs — time only runs once and hyperfine requires a Rust installation most Node developers don't have.

If you've hit this before, you know how it goes — you either run the command once with time, install hyperfine via brew or cargo, or just eyeball the timing.

As a solution, I created bench-run

Benchmark any shell command with min/max/avg/median timing over N runs

It's zero-dependency Node.js, so you can run it immediately without installing anything:

npx bench-run "npm test" --runs 5
Enter fullscreen mode Exit fullscreen mode

Output:

bench-run: npm test
Runs: 5

  Run 1/5... 4.231s
  Run 2/5... 4.108s
  Run 3/5... 4.189s
  Run 4/5... 4.212s
  Run 5/5... 4.095s

──────────────────────────────────────
  min     4.095s
  max     4.231s
  avg     4.167s
  median  4.189s
  stddev  0.055s
──────────────────────────────────────
Enter fullscreen mode Exit fullscreen mode

How it works

Pure Node.js using child_process.execSync with process.hrtime.bigint() for nanosecond-precision timing; results are aggregated after all runs complete and printed as a summary table.

Why I built it

Found repeated Ask HN and r/devops threads asking how to benchmark a build script — the top answers always link to hyperfine, which requires cargo or brew. Developers who already have Node installed have no zero-dep equivalent that works via npx. The problem also shows up in CI: teams want to track whether their test suite is getting slower across PRs but have no lightweight way to do it without adding a heavy benchmarking framework.

Try it

npx bench-run --help
Enter fullscreen mode Exit fullscreen mode

Part of µ micro — one new developer CLI tool, shipped every day. All tools are zero-dependency Node.js and run instantly with npx.

Top comments (0)