nodejs-package-benchmark
This package allows you to benchmark different runtimes using popular
packages operations.
Supported packages
Install
npm i -g nodejs-package-benchmark
Comparison
To compare binaries, you can use the bench-it script.
Syntax: bench-it $BINARY ["baseline"]
This script allows you to compare the performance of binaries. If it's your first run, you need to generate the baseline data using:
$ bench-it ./node baseline
To compare subsequent runs, simply omit the "baseline" option:
[!TIP]
It's recommended to have colordiff installed for a clearer comparison of differences.
Single run
To a pretty terminal output, run index.js
$ node --allow-natives-syntax index.js
cpu: 13th Gen Intel(R) Core(TM) i5-13600K (20 cores)
node: v20.13.1 (/home/hzk/.nvm/versions/node/v20.13.1/bin/node)
os: Linux 5.15.133.1-microsoft-standard-WSL2 x64
---------------------------------------------------------------------
babel
transform (code=true ast=true): 147.1 (15 samples)
transform (code=false): 150.4 (16 samples)
dotenv
config: 64.39K (6440 samples)
lodash
.chunk: 19.62M (1961973 samples)
.groupBy: 6.303M (630542 samples)
.includes: 18.38M (1837801 samples)
.orderBy: 1.737M (173672 samples)
moment
format (full): 878.8K (87908 samples)
format: 839.3K (83928 samples)
fromNow (YYYYMMDD): 153.4K (15339 samples)
subtract (10): 288.7K (28871 samples)
pinojs
info (10x): 243.7K (24686 samples)
To store it as JSON, just pipe output to a file:
$ node index.js > results.json
$ cat result.json
[
{
"name": "babel",
"method": "benchmarkjs",
"operations": [
{
"name": "transform (code=true ast=true)",
"opsSec": 67.80076532539411,
"samples": 3
},
{
...