Files
James M Snell 409242ca8c lib: complete the implementation of node:bench and cli
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode
PR-URL: https://github.com/nodejs/node/pull/65606
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-09-03 15:37:21 +00:00

32 lines
860 B
JavaScript

'use strict';
const {
ArrayPrototypeSlice,
PromisePrototypeThen,
} = primordials;
const {
markBootstrapComplete,
prepareTestRunnerMainExecution,
} = require('internal/process/pre_execution');
const { emitExperimentalWarning } = require('internal/util');
const {
triggerUncaughtException,
exitCodes: { kGenericUserError },
} = internalBinding('errors');
prepareTestRunnerMainExecution();
markBootstrapComplete();
if (process.env.NODE_BENCH_CONTEXT !== 'child' ||
typeof process.send !== 'function') {
emitExperimentalWarning('Benchmarks');
}
const { run } = require('internal/bench_runner/cli');
const patterns = ArrayPrototypeSlice(process.argv, 1);
PromisePrototypeThen(run(patterns), ({ success }) => {
if (!success) process.exitCode = kGenericUserError;
}, (error) => {
triggerUncaughtException(error, true /* fromPromise */);
});