mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
7d28de9a79
PR-URL: https://github.com/nodejs/node/pull/55757 Refs: https://github.com/nodejs/node/issues/55723 Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Raz Luvaton <rluvaton@gmail.com>
42 lines
1004 B
JavaScript
42 lines
1004 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { run } = require('node:test');
|
|
const reporters = require('node:test/reporters');
|
|
const { Readable } = require('node:stream');
|
|
const assert = require('node:assert');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [1e4],
|
|
reporter: Object.keys(reporters),
|
|
});
|
|
|
|
// No need to run this for every benchmark,
|
|
// it should always be the same data.
|
|
const stream = run({
|
|
files: ['../fixtures/basic-test-runner.js'],
|
|
});
|
|
let testResults;
|
|
|
|
async function main({ n, reporter: r }) {
|
|
testResults ??= await stream.toArray();
|
|
|
|
// Create readable streams for each iteration
|
|
const readables = Array.from({ length: n }, () => Readable.from(testResults));
|
|
|
|
// Get the selected reporter
|
|
const reporter = reporters[r];
|
|
|
|
bench.start();
|
|
|
|
let noDead;
|
|
for (const readable of readables) {
|
|
// Process each readable stream through the reporter
|
|
noDead = await readable.compose(reporter).toArray();
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
assert.ok(noDead);
|
|
}
|