Skip to content

Commit d3c2853

Browse files
committed
test_runner: add multiple files benchmark
1 parent bf26bca commit d3c2853

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

benchmark/test_runner/multi-files.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
const bench = common.createBenchmark(main, {
5+
patterns: ['test/fixtures/test-runner/**/*.?(c|m)js', 'test/parallel/test-runner-*'],
6+
concurrency: ['yes', 'no'],
7+
}, {
8+
flags: ['--expose-internals'],
9+
});
10+
11+
12+
function main({ patterns, concurrency }) {
13+
const { run } = require('node:test');
14+
const { Glob } = require('internal/fs/glob');
15+
const glob = new Glob([patterns]);
16+
const files = glob.globSync().filter((f) => !f.includes('never_ending') && !f.includes('watch-mode'));
17+
concurrency = concurrency === 'yes';
18+
let tests = 0;
19+
20+
bench.start();
21+
(async function() {
22+
const stream = run({ concurrency, files });
23+
for await (const { type } of stream) {
24+
if (type === 'test:start') tests++;
25+
}
26+
})().then(() => bench.end(tests));
27+
}

benchmark/test_runner/suite-tests.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
'use strict';
22
const common = require('../common');
3-
const { finished } = require('node:stream/promises');
4-
5-
const reporter = require('../fixtures/empty-test-reporter');
63

74
const { describe, it } = require('node:test');
85

96
const bench = common.createBenchmark(main, {
107
numberOfSuites: [10, 100],
11-
testsPerSuite: [10, 100, 1000],
8+
testsPerSuite: [10, 100],
129
testType: ['sync', 'async'],
1310
concurrency: ['yes', 'no'],
1411
}, {
@@ -52,8 +49,6 @@ async function run({ numberOfSuites, testsPerSuite, testType, concurrency }) {
5249
}
5350
}
5451

55-
await finished(reporter);
56-
5752
return numberOfSuites * testsPerSuite;
5853
}
5954

0 commit comments

Comments
 (0)