Skip to content
Eugene Lazutkin edited this page Jul 20, 2024 · 14 revisions

nano-benchmark provides command-line utilities for benchmarking code and related statistical modules. Node, Deno and Bun are supported.

Two utilities are available:

  • nano-watch — provides statistics in a streaming mode continuously running your code, watching memory usage and updating the output.
  • nano-bench — runs benchmark tests on your code, calculating statistics and statistical significance, and presenting them as a table.

It is advisable to familiarize yourself with the underlying concepts first.

Deno, Bun, etc.

If you want to run the utilities in Deno, Bun, etc. you can specify self as the file argument or use the --self option. In this case the utility will print out its file name to stdout and exit. It allows running the utility with alternative JavaScript interpreters.

Examples with bash:

$ npx nano-bench benchmark.js
$ bun `npx nano-bench --self` benchmark.js
$ deno run --allow-read --allow-hrtime `npx nano-bench --self` benchmark.js
$ deno run -A `npx nano-bench --self` benchmark.js
$ node `npx nano-bench --self` benchmark.js

Clone this wiki locally