forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsuite-tests.js
More file actions
65 lines (53 loc) · 1.49 KB
/
suite-tests.js
File metadata and controls
65 lines (53 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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);
});
}