Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark: rename count to n #54271

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions benchmark/misc/startup-cli-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ const availableCli = [
].filter((cli) => existsSync(path.resolve(__dirname, '../../', cli)));
const bench = common.createBenchmark(main, {
cli: availableCli,
count: [30],
n: [30],
});

function spawnProcess(cli, bench, state) {
const cmd = process.execPath || process.argv[0];
while (state.finished < state.count) {
while (state.finished < state.n) {
const child = spawnSync(cmd, [cli, '--version'], {
env: { npm_config_loglevel: 'silent', ...process.env },
});
Expand All @@ -41,15 +41,15 @@ function spawnProcess(cli, bench, state) {
bench.start();
}

if (state.finished === state.count) {
bench.end(state.count);
if (state.finished === state.n) {
bench.end(state.n);
}
}
}

function main({ count, cli }) {
function main({ n, cli }) {
cli = path.resolve(__dirname, '../../', cli);
const warmup = 3;
const state = { count, finished: -warmup };
const state = { n, finished: -warmup };
spawnProcess(cli, bench, state);
}
16 changes: 8 additions & 8 deletions benchmark/misc/startup-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ const bench = common.createBenchmark(main, {
'test/fixtures/snapshot/typescript',
],
mode: ['process', 'worker'],
count: [30],
n: [30],
});

function spawnProcess(script, bench, state) {
const cmd = process.execPath || process.argv[0];
while (state.finished < state.count) {
while (state.finished < state.n) {
const child = spawnSync(cmd, [script]);
if (child.status !== 0) {
console.log('---- STDOUT ----');
Expand All @@ -32,8 +32,8 @@ function spawnProcess(script, bench, state) {
bench.start();
}

if (state.finished === state.count) {
bench.end(state.count);
if (state.finished === state.n) {
bench.end(state.n);
}
}
}
Expand All @@ -49,18 +49,18 @@ function spawnWorker(script, bench, state) {
// Finished warmup.
bench.start();
}
if (state.finished < state.count) {
if (state.finished < state.n) {
spawnWorker(script, bench, state);
} else {
bench.end(state.count);
bench.end(state.n);
}
});
}

function main({ count, script, mode }) {
function main({ n, script, mode }) {
script = path.resolve(__dirname, '../../', `${script}.js`);
const warmup = 3;
const state = { count, finished: -warmup };
const state = { n, finished: -warmup };
if (mode === 'worker') {
Worker = require('worker_threads').Worker;
spawnWorker(script, bench, state);
Expand Down
Loading