Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 8 additions & 0 deletions benchmark/fixtures/empty-test-reporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { PassThrough } = require('node:stream');

module.exports = new PassThrough({
objectMode: true,
transform(chunk, encoding, callback) {
callback(null)
},
});
27 changes: 27 additions & 0 deletions benchmark/test_runner/plain-tests-as-fast-as-can.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';
const common = require('../common');
const { it } = require('node:test');

const bench = common.createBenchmark(main, {
n: [100, 1000, 1e4],
}, {
// We don't want to test the reporter here
flags: ['--test-reporter=./benchmark/fixtures/empty-test-reporter.js'],
});

async function run(n) {
const promises = new Array(n);
for (let i = 0; i < n; i++) {
promises[i] = it(`${i}`, () => {
});
}

await Promise.all(promises);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use finished on the reporter or this?

}

function main({ n }) {
bench.start();
run(n).then(() => {
bench.end(n);
});
}
25 changes: 25 additions & 0 deletions benchmark/test_runner/plain-tests-waiting-for-each-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';
const common = require('../common');
const { it } = require('node:test');


const bench = common.createBenchmark(main, {
n: [100, 1000, 1e4],
}, {
// We don't want to test the reporter here
flags: ['--test-reporter=./benchmark/fixtures/empty-test-reporter.js'],
});

async function run(n) {
for (let i = 0; i < n; i++) {
await it(`${i}`, () => {
});
}
}

function main({ n }) {
bench.start();
run(n).then(() => {
bench.end(n);
});
}
37 changes: 37 additions & 0 deletions benchmark/test_runner/suite-tests-as-fast-as-can.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'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],
}, {
// We don't want to test the reporter here
flags: ['--test-reporter=./benchmark/fixtures/empty-test-reporter.js'],
});

async function run(numberOfSuites, testsPerSuite) {
for (let i = 0; i < numberOfSuites; i++) {
describe(`${i}`, () => {
for (let j = 0; j < testsPerSuite; j++) {
it(`${j}`, () => {
});
}
});
}

await finished(reporter);

return numberOfSuites * testsPerSuite;
}

function main({ numberOfSuites, testsPerSuite }) {
bench.start();
run(numberOfSuites, testsPerSuite).then((ops) => {
bench.end(ops);
});
}