-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark.js
37 lines (31 loc) · 986 Bytes
/
benchmark.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
const Benchmark = require('benchmark');
const fs = require('fs')
const assert = require('assert');
let flows = fs.readdirSync('flows')
for (flow of flows) {
console.log(`creating suite for flow: ${flow}`)
let tests = fs.readdirSync(`flows/${flow}`);
let suite = new Benchmark.Suite;
for (test of tests) {
let fn = require(`./flows/${flow}/${test}`)
suite
.add(test, {
defer: true,
fn: (deferred) => {
fn(function(err, product) {
deferred.resolve();
assert.equal(product, 24, `wrong value for test ${test}, expected 24, got ${product}, ${err}`);
})
}
})
}
suite.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('end');
})
.run({
async: true
})
}