Skip to content

Commit

Permalink
benchmark: move non-present deps down the list
Browse files Browse the repository at this point in the history
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: #51146
  • Loading branch information
AdamMajer committed Feb 14, 2024
1 parent 544cfc5 commit 91bba09
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions benchmark/misc/startup-cli-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
});

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 91bba09

Please sign in to comment.