Skip to content

Commit 93ee36e

Browse files
RafaelGSStargos
authored andcommitted
benchmark: rename count to n
It's a common approach to use n as number of iterations over the benchmark. Changing it from count to n will also make ./node benchmark/run.js --set n=X more meaningful among other benchmarks PR-URL: #54271 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 6a4f05e commit 93ee36e

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

benchmark/misc/startup-cli-version.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ const availableCli = [
1818
].filter((cli) => existsSync(path.resolve(__dirname, '../../', cli)));
1919
const bench = common.createBenchmark(main, {
2020
cli: availableCli,
21-
count: [30],
21+
n: [30],
2222
});
2323

2424
function spawnProcess(cli, bench, state) {
2525
const cmd = process.execPath || process.argv[0];
26-
while (state.finished < state.count) {
26+
while (state.finished < state.n) {
2727
const child = spawnSync(cmd, [cli, '--version'], {
2828
env: { npm_config_loglevel: 'silent', ...process.env },
2929
});
@@ -41,15 +41,15 @@ function spawnProcess(cli, bench, state) {
4141
bench.start();
4242
}
4343

44-
if (state.finished === state.count) {
45-
bench.end(state.count);
44+
if (state.finished === state.n) {
45+
bench.end(state.n);
4646
}
4747
}
4848
}
4949

50-
function main({ count, cli }) {
50+
function main({ n, cli }) {
5151
cli = path.resolve(__dirname, '../../', cli);
5252
const warmup = 3;
53-
const state = { count, finished: -warmup };
53+
const state = { n, finished: -warmup };
5454
spawnProcess(cli, bench, state);
5555
}

benchmark/misc/startup-core.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ const bench = common.createBenchmark(main, {
1111
'test/fixtures/semicolon',
1212
],
1313
mode: ['process', 'worker'],
14-
count: [30],
14+
n: [30],
1515
});
1616

1717
function spawnProcess(script, bench, state) {
1818
const cmd = process.execPath || process.argv[0];
19-
while (state.finished < state.count) {
19+
while (state.finished < state.n) {
2020
const child = spawnSync(cmd, [script]);
2121
if (child.status !== 0) {
2222
console.log('---- STDOUT ----');
@@ -31,8 +31,8 @@ function spawnProcess(script, bench, state) {
3131
bench.start();
3232
}
3333

34-
if (state.finished === state.count) {
35-
bench.end(state.count);
34+
if (state.finished === state.n) {
35+
bench.end(state.n);
3636
}
3737
}
3838
}
@@ -48,18 +48,18 @@ function spawnWorker(script, bench, state) {
4848
// Finished warmup.
4949
bench.start();
5050
}
51-
if (state.finished < state.count) {
51+
if (state.finished < state.n) {
5252
spawnWorker(script, bench, state);
5353
} else {
54-
bench.end(state.count);
54+
bench.end(state.n);
5555
}
5656
});
5757
}
5858

59-
function main({ count, script, mode }) {
59+
function main({ n, script, mode }) {
6060
script = path.resolve(__dirname, '../../', `${script}.js`);
6161
const warmup = 3;
62-
const state = { count, finished: -warmup };
62+
const state = { n, finished: -warmup };
6363
if (mode === 'worker') {
6464
Worker = require('worker_threads').Worker;
6565
spawnWorker(script, bench, state);

0 commit comments

Comments
 (0)