-
Notifications
You must be signed in to change notification settings - Fork 64
/
index.ts
93 lines (78 loc) · 2.67 KB
/
index.ts
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import * as childProcess from 'child_process';
import * as benchmarks from './benchmarks';
import * as cases from './cases';
async function main() {
// a runtype lib would be handy here to check the passed command names ;)
const [command, ...args] = process.argv.slice(2);
switch (command) {
case undefined:
case 'run':
// run the given or all benchmarks, each in its own node process, see
// https://github.com/moltar/typescript-runtime-type-benchmarks/issues/864
{
console.log('Removing previous results');
benchmarks.deleteResults();
const caseNames = args.length ? args : cases.cases;
for (const c of caseNames) {
// hack: manually run the spectypes and ts-runtime-checks compilation step - avoids
// having to run it before any other benchmark, esp when working
// locally and checking against a few selected ones.
if (c === 'spectypes') {
childProcess.execSync('npm run compile:spectypes', {
stdio: 'inherit',
});
}
if (c === 'ts-runtime-checks') {
childProcess.execSync('npm run compile:ts-runtime-checks', {
stdio: 'inherit',
});
}
if (c === 'typia') {
childProcess.execSync('npm run compile:typia', {
stdio: 'inherit',
});
}
if (c === 'deepkit') {
childProcess.execSync('npm run compile:deepkit', {
stdio: 'inherit',
});
}
if (c === 'ts-auto-guard') {
childProcess.execSync('npm run compile:ts-auto-guard', {
stdio: 'inherit',
});
}
const cmd = [...process.argv.slice(0, 2), 'run-internal', c];
console.log('Executing "%s"', c);
childProcess.execFileSync(cmd[0], cmd.slice(1), {
shell: false,
stdio: 'inherit',
});
}
}
break;
case 'create-preview-svg':
// separate command, because preview generation needs the accumulated
// results from the benchmark runs
await benchmarks.createPreviewGraph();
break;
case 'run-internal':
// run the given benchmark(s) & append the results
{
const caseNames = args as cases.CaseName[];
for (const c of caseNames) {
console.log('Loading "%s"', c);
await cases.importCase(c);
}
await benchmarks.runAllBenchmarks();
}
break;
default:
console.error('unknown command:', command);
//eslint-disable-next-line n/no-process-exit
process.exit(1);
}
}
main().catch(e => {
throw e;
});