Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion benchmark/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const path = require('path');
const { spawn, fork } = require('node:child_process');
const CLI = require('./_cli.js');
const { styleText } = require('node:util');

const cli = new CLI(`usage: ./node run.js [options] [--] <category> ...
Run each benchmark in the <category> directory a single time, more than one
Expand All @@ -16,6 +17,7 @@ const cli = new CLI(`usage: ./node run.js [options] [--] <category> ...
Default: 1
--set variable=value set benchmark variable (can be repeated)
--format [simple|csv] optional value that specifies the output format
--track Display the time elapsed to run each benchmark file.
test only run a single configuration from the options
matrix
all each benchmark category is run one after the other
Expand All @@ -25,7 +27,7 @@ const cli = new CLI(`usage: ./node run.js [options] [--] <category> ...
--set CPUSET=0-2 Specifies that benchmarks should run on CPU cores 0 to 2.

Note: The CPUSET format should match the specifications of the 'taskset' command on your system.
`, { arrayArgs: ['set', 'filter', 'exclude'] });
`, { arrayArgs: ['set', 'filter', 'exclude'], boolArgs: ['track'] });

const benchmarks = cli.benchmarks();

Expand Down Expand Up @@ -107,7 +109,12 @@ async function run() {
}

while (runs-- > 0) {
const start = performance.now();
await runBenchmark(filename);
if (format !== 'csv' && cli.optional.track) {
const ms = styleText(['bold', 'yellow'], `${Math.round(performance.now() - start)}ms`);
console.log(`[${ms}] ${filename}`);
}
}
}
}
Expand Down
Loading