forked from Rugvip/ts-build-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark-typecheck
executable file
·74 lines (70 loc) · 2.03 KB
/
benchmark-typecheck
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
66
67
68
69
70
71
72
73
74
#!/usr/bin/env node
const { createProjectMatrix, presets } = require('./factory');
const { processRunner } = require('./runner');
const { printTimingSummary } = require('./stats');
processRunner({
matrix: createProjectMatrix({
baseConfig: presets.baseConfig({
packages: Array(100).fill(presets.packages.balanced(20)),
}),
dimensions: [
{
topInc: {
lintStrategy: 'top',
projectReferences: 'incremental',
},
allRefs: {
lintStrategy: 'all',
projectReferences: 'enabled',
},
topRefs: {
lintStrategy: 'top-references',
projectReferences: 'enabled',
},
},
],
}),
prepare: async (runner) => {},
benchmark: async (runner, count) => {
const timings1 = await runner.time(
count,
async (runner) => {
await runner.runCmd('.', ['yarn', 'lint']);
},
async (runner, isLastRun) => {
if (!isLastRun) {
if (runner.project.dir.includes('topInc')) {
await runner.runCmd('.', ['rm', '-r', 'types-cache']);
} else {
await runner.runCmd('.', ['yarn', 'clean']);
}
}
}
);
console.log('*** FIRST LINT TIMES ***');
printTimingSummary(timings1);
const timings2 = await runner.timeCmd({ cmd: ['yarn', 'lint'], count });
console.log('*** SECOND LINT TIMES ***');
printTimingSummary(timings2);
const timings4 = await runner.time(count, async (runner) => {
runner.runCmd('packages/pkg1/src/components/component-1', [
'sed',
'-i',
'""',
's/a\\?/x\\?/',
'Component.tsx',
]);
await runner.runCmd('.', ['yarn', 'lint'], { expectFail: true });
runner.runCmd('packages/pkg1/src/components/component-1', [
'sed',
'-i',
'""',
's/x\\?/a\\?/',
'Component.tsx',
]);
await runner.runCmd('.', ['yarn', 'lint']);
});
console.log('*** CHANGED LINT TIMES ***');
printTimingSummary(timings4);
},
});