Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
test_runner: add multiple files benchmark
  • Loading branch information
MoLow committed Aug 16, 2023
commit 378ded51e8b6edcba456f6625da571604f21b178
27 changes: 27 additions & 0 deletions benchmark/test_runner/multi-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';
const common = require('../common');

const bench = common.createBenchmark(main, {
patterns: ['test/fixtures/test-runner/**/*.?(c|m)js', 'test/parallel/test-runner-*'],
concurrency: ['yes', 'no'],
}, {
flags: ['--expose-internals'],
Comment thread
MoLow marked this conversation as resolved.
});


function main({ patterns, concurrency }) {
const { run } = require('node:test');
const { Glob } = require('internal/fs/glob');
const glob = new Glob([patterns]);
const files = glob.globSync().filter((f) => !f.includes('never_ending') && !f.includes('watch-mode'));
concurrency = concurrency === 'yes';
let tests = 0;

bench.start();
(async function() {
const stream = run({ concurrency, files });
for await (const { type } of stream) {
if (type === 'test:start') tests++;
}
})().then(() => bench.end(tests));
}
7 changes: 1 addition & 6 deletions benchmark/test_runner/suite-tests.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
'use strict';
const common = require('../common');
const { finished } = require('node:stream/promises');

const reporter = require('../fixtures/empty-test-reporter');

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

const bench = common.createBenchmark(main, {
numberOfSuites: [10, 100],
testsPerSuite: [10, 100, 1000],
testsPerSuite: [10, 100],
testType: ['sync', 'async'],
concurrency: ['yes', 'no'],
}, {
Expand Down Expand Up @@ -52,8 +49,6 @@ async function run({ numberOfSuites, testsPerSuite, testType, concurrency }) {
}
}

await finished(reporter);

return numberOfSuites * testsPerSuite;
}

Expand Down