From 91bba09428f8e79302c2317444246ddeeba4f614 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Tue, 13 Feb 2024 13:11:24 +0100 Subject: [PATCH] benchmark: move non-present deps down the list In previous version of this fix, I've simply added a check if the tested tool is available or not. Unfortuntelly, this fails when only the first tool is to be run as part of the test-benchmark-misc, and it doesn't exist. benchmark/test-benchmark-misc ... AssertionError [ERR_ASSERTION]: benchmark file not running exactly one configuration in test: ... misc/startup-cli-version.js ... One solution is to check if the cli tool is actually available before using it in a benchmark Refs: https://github.com/nodejs/node/pull/51146 --- benchmark/misc/startup-cli-version.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/benchmark/misc/startup-cli-version.js b/benchmark/misc/startup-cli-version.js index 4dbeb81fc70740..0c8d4848b46cd4 100644 --- a/benchmark/misc/startup-cli-version.js +++ b/benchmark/misc/startup-cli-version.js @@ -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);