benchmark: filter non-present deps from `start-cli-version`

PR-URL: https://github.com/nodejs/node/pull/51746
Refs: https://github.com/nodejs/node/pull/51146
Refs: https://github.com/nodejs/node/pull/50684
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
pull/34066/head
Adam Majer 2024-05-11 17:25:23 +02:00 committed by GitHub
parent c4d0229486
commit b1515c7a6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 10 deletions

View File

@ -9,13 +9,15 @@ const path = require('path');
// tends to be minimal and fewer operations are done to generate
// these so that the startup cost is still dominated by a more
// indispensible part of the CLI.
// NOTE: not all tools are present in tarball hence need to filter
const availableCli = [
'tools/node_modules/eslint/bin/eslint.js',
'deps/npm/bin/npx-cli.js',
'deps/npm/bin/npm-cli.js',
'deps/corepack/dist/corepack.js',
].filter((cli) => existsSync(path.resolve(__dirname, '../../', cli)));
const bench = common.createBenchmark(main, {
cli: [
'tools/node_modules/eslint/bin/eslint.js',
'deps/npm/bin/npx-cli.js',
'deps/npm/bin/npm-cli.js',
'deps/corepack/dist/corepack.js',
],
cli: availableCli,
count: [30],
});
@ -47,10 +49,6 @@ function spawnProcess(cli, bench, state) {
function main({ count, cli }) {
cli = path.resolve(__dirname, '../../', cli);
if (!existsSync(cli)) {
return;
}
const warmup = 3;
const state = { count, finished: -warmup };
spawnProcess(cli, bench, state);