Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,46 @@
'use strict';
const common = require('../common');
const { it } = require('node:test');
const bench = common.createBenchmark(main, {
n: [100, 1000, 1e4],
type: ['sync', 'async'],
}, {
// We don't want to test the reporter here
flags: ['--test-reporter=./benchmark/fixtures/empty-test-reporter.js'],
});
async function run(n, type) {
const promises = new Array(n);
// eslint-disable-next-line no-unused-vars
let avoidV8Optimization;
switch (type) {
case 'sync': {
for (let i = 0; i < n; i++) {
promises[i] = it(`${i}`, () => {
avoidV8Optimization = i;
});
}
break;
}
case 'async':
for (let i = 0; i < n; i++) {
promises[i] = it(`${i}`, async () => {
avoidV8Optimization = i;
});
}
break;
}
await Promise.all(promises);
}
function main({ n, type }) {
bench.start();
run(n, type).then(() => {
bench.end(n);
});
}

View File

@ -0,0 +1,46 @@
'use strict';
const common = require('../common');
const { it } = require('node:test');
const bench = common.createBenchmark(main, {
n: [100, 1000, 1e4],
type: ['sync', 'async'],
}, {
// We don't want to test the reporter here
flags: ['--test-reporter=./benchmark/fixtures/empty-test-reporter.js'],
});
async function run(n, type) {
// eslint-disable-next-line no-unused-vars
let avoidV8Optimization;
const promises = new Array(n);
switch (type) {
case 'sync': {
for (let i = 0; i < n; i++) {
await it(`${i}`, () => {
avoidV8Optimization = i;
});
}
break;
}
case 'async':
for (let i = 0; i < n; i++) {
await it(`${i}`, async () => {
avoidV8Optimization = i;
});
}
break;
}
await Promise.all(promises);
}
function main({ n }) {
bench.start();
run(n).then(() => {
bench.end(n);
});
}

View File

@ -0,0 +1,48 @@
'use strict';
const common = require('../common');
const assert = require('node:assert');
const { test } = require('node:test');
const bench = common.createBenchmark(main, {
n: [1e6],
mode: ['define', 'execute'],
}, {
// We don't want to test the reporter here
flags: ['--test-reporter=./benchmark/fixtures/empty-test-reporter.js'],
});
const noop = () => {};
function benchmarkDefine(n) {
let noDead;
test((t) => {
bench.start();
for (let i = 0; i < n; i++) {
noDead = t.mock.fn(noop);
}
bench.end(n);
assert.ok(noDead);
});
}
function benchmarkExecute(n) {
let noDead;
test((t) => {
const mocked = t.mock.fn(noop);
bench.start();
for (let i = 0; i < n; i++) {
noDead = mocked();
}
bench.end(n);
assert.strictEqual(noDead, noop());
});
}
function main({ n, mode }) {
if (mode === 'define') {
benchmarkDefine(n);
} else if (mode === 'execute') {
benchmarkExecute(n);
}
}

View File

@ -0,0 +1,62 @@
'use strict';
const common = require('../common');
const tmpdir = require('../../test/common/tmpdir');
const { run } = require('node:test');
const { writeFileSync, mkdirSync } = require('node:fs');
const { join } = require('node:path');
const fixtureContent = "const test = require('node:test'); test('test has ran');";
function makeTestDirWithFiles(dirPath, count) {
mkdirSync(dirPath);
for (let i = 0; i < count; i++) {
writeFileSync(join(dirPath, `test-${i}.js`), fixtureContent);
}
}
function getTestDirPath(numberOfTestFiles) {
return join(tmpdir.path, `${numberOfTestFiles}-tests`);
}
function setup(numberOfTestFiles) {
tmpdir.refresh();
const dirPath = getTestDirPath(numberOfTestFiles);
makeTestDirWithFiles(dirPath, numberOfTestFiles);
}
/**
* This benchmark evaluates the overhead of running a single test file under different
* isolation modes.
* Specifically, it compares the performance of running tests in the
* same process versus creating multiple processes.
*/
const bench = common.createBenchmark(main, {
numberOfTestFiles: [1, 10, 100],
isolation: ['none', 'process'],
}, {
// We don't want to test the reporter here
flags: ['--test-reporter=./benchmark/fixtures/empty-test-reporter.js'],
});
async function runBenchmark({ numberOfTestFiles, isolation }) {
const dirPath = getTestDirPath(numberOfTestFiles);
const stream = run({
cwd: dirPath,
isolation,
concurrency: false, // We don't want to run tests concurrently
});
// eslint-disable-next-line no-unused-vars
for await (const _ of stream);
return numberOfTestFiles;
}
function main(params) {
setup(params.numberOfTestFiles);
bench.start();
runBenchmark(params).then(() => {
bench.end(1);
});
}

View File

@ -0,0 +1,65 @@
'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],
testType: ['sync', 'async'],
concurrency: ['yes', 'no'],
}, {
// We don't want to test the reporter here
flags: ['--test-reporter=./benchmark/fixtures/empty-test-reporter.js'],
});
async function run({ numberOfSuites, testsPerSuite, testType, concurrency }) {
concurrency = concurrency === 'yes';
// eslint-disable-next-line no-unused-vars
let avoidV8Optimization;
switch (testType) {
case 'sync': {
for (let i = 0; i < numberOfSuites; i++) {
describe(`${i}`, { concurrency }, () => {
for (let j = 0; j < testsPerSuite; j++) {
it(`${j}`, () => {
avoidV8Optimization = i;
});
}
});
}
break;
}
case 'async': {
for (let i = 0; i < numberOfSuites; i++) {
describe(`${i}`, { concurrency }, () => {
for (let j = 0; j < testsPerSuite; j++) {
it(`${j}`, async () => {
avoidV8Optimization = i;
});
}
});
}
break;
}
}
await finished(reporter);
return numberOfSuites * testsPerSuite;
}
function main(params) {
bench.start();
run(params).then((ops) => {
bench.end(ops);
});
}

View File

@ -0,0 +1,41 @@
'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);
}