forked from Tinkoff/utils.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunBenchmark.js
More file actions
43 lines (33 loc) · 1.04 KB
/
runBenchmark.js
File metadata and controls
43 lines (33 loc) · 1.04 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
/* eslint-disable import/no-commonjs,global-require,no-console */
require('babel-register')();
const path = require('path');
const walker = require('walker');
const Suite = require('benchmark').Suite;
function createSuite(name, tests) {
const suite = new Suite(name);
for (const key in tests) {
suite.add(key, tests[key]);
}
console.log(`${name}:`);
return suite
.on('cycle', event => {
console.log(String(event.target));
})
.on('complete', () => {
console.log('_________________\n');
});
}
const filterRegex = process.argv[2] ? new RegExp(process.argv[2]) : null;
walker(path.resolve(__dirname, 'src'))
.filterDir(dir => {
return !/node_modules/.test(dir);
})
.on('file', file => {
if (filterRegex && !filterRegex.test(file)) {
return;
}
if (/__benchmarks__/.test(file)) {
const tests = require(file).default;
createSuite(path.relative(__dirname, file), tests).run();
}
});