Skip to content

Commit 9b3d22d

Browse files
authored
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: nodejs#54271 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent b49019e commit 9b3d22d

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
@@ -12,12 +12,12 @@ const bench = common.createBenchmark(main, {
1212
'test/fixtures/snapshot/typescript',
1313
],
1414
mode: ['process', 'worker'],
15-
count: [30],
15+
n: [30],
1616
});
1717

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

35-
if (state.finished === state.count) {
36-
bench.end(state.count);
35+
if (state.finished === state.n) {
36+
bench.end(state.n);
3737
}
3838
}
3939
}
@@ -49,18 +49,18 @@ function spawnWorker(script, bench, state) {
4949
// Finished warmup.
5050
bench.start();
5151
}
52-
if (state.finished < state.count) {
52+
if (state.finished < state.n) {
5353
spawnWorker(script, bench, state);
5454
} else {
55-
bench.end(state.count);
55+
bench.end(state.n);
5656
}
5757
});
5858
}
5959

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

0 commit comments

Comments
 (0)