-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmarks.js
74 lines (57 loc) · 1.63 KB
/
benchmarks.js
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
var fs = require('fs');
var path = require('path');
var benchmarksDir = path.join(__dirname, 'benchmarks');
var benchmarks = [];
var enabledLibs = null;
var enabledBenchmarks = null;
// enabledLibs = {
// preact: false,
// react: false,
// marko: true,
// vue: false,
// inferno: false
// };
//
// enabledBenchmarks = {
// 'search-results': true,
// 'color-picker': false
// };
fs.readdirSync(benchmarksDir).forEach((benchmarkName) => {
var benchmarkDir = path.join(benchmarksDir, benchmarkName);
if (!fs.statSync(benchmarkDir).isDirectory()) {
// Only look at directories
return;
}
if (enabledBenchmarks && !enabledBenchmarks[benchmarkName]) {
return;
}
var benchmark = {
name: benchmarkName,
dir: benchmarkDir,
benches: [],
createRoute: require(path.join(benchmarkDir, 'createRoute')),
serverFactory: require(path.join(benchmarkDir, 'server'))
};
benchmarks.push(benchmark);
fs.readdirSync(benchmarkDir).forEach((libName) => {
if (libName === 'util') {
return;
}
if (enabledLibs && !enabledLibs[libName]) {
return;
}
var libDir = path.join(benchmarkDir, libName);
if (!fs.statSync(libDir).isDirectory()) {
// Only look at directories
return;
}
var bench = {
dir: libDir,
name: libName,
url: `/${benchmarkName}/${libName}`,
serverFactory: require(path.join(libDir, 'server'))
};
benchmark.benches.push(bench);
});
});
module.exports = benchmarks;