-
Notifications
You must be signed in to change notification settings - Fork 38
/
benchmarks.js
76 lines (62 loc) · 1.67 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
75
76
var fs = require("fs");
var path = require("path");
var benchmarksDir = path.join(__dirname, "benchmarks");
var benchmarks = [];
var enabledLibs = null;
var enabledBenchmarks = null;
enabledLibs = {
marko: true,
preact: true,
react: true,
vue: true,
inferno: true
};
enabledBenchmarks = {
"search-results": true,
"color-picker": true
};
Object.keys(enabledBenchmarks).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: function() {
var createRoute = require(path.join(benchmarkDir, "createRoute"));
return createRoute.apply(this, arguments);
},
serverFactory: function() {
var serverFactory = require(path.join(benchmarkDir, "server"));
return serverFactory.apply(this, arguments);
}
};
benchmarks.push(benchmark);
Object.keys(enabledLibs).forEach(libName => {
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: function() {
var serverFactory = require(path.join(libDir, "server"));
return serverFactory.apply(this, arguments);
}
};
benchmark.benches.push(bench);
});
});
module.exports = benchmarks;