mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
benchmark: add --track to benchmark
This option will measure how long the benchmark takes to run. Example: ``` $ ./node benchmark/run.js --track assert assert/assertion-error.js assert/assertion-error.js size=2 n=200: 22,987.24012781365 assert/assertion-error.js size=75 n=200: 296.2362823364434 [740ms] assert/assertion-error.js ... ``` Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: https://github.com/nodejs/node/pull/59174 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
This commit is contained in:
parent
d5b815c9ea
commit
5f3aa57210
1 changed files with 8 additions and 1 deletions
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue