-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
59 lines (49 loc) · 1.49 KB
/
app.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
var Benchmark = require('benchmark');
var readline = require('readline');
var tests = require('./test.js');
var suite = new Benchmark.Suite('Test', {
// called when the suite starts running
'onStart': function () {
console.log('-----------------------------------------------');
console.log('Running Benchmarking Suite, please be patient.');
console.log('');
},
// called between running benchmarks
'onCycle': function (event) {
console.log(String(event.target));
},
// called when aborted
'onAbort': function () {
console.log('Abortet!');
},
// called when a test errors
'onError': function (err) {
console.log('An err occured:');
console.log(err);
},
// called when the suite completes running
'onComplete': function () {
console.log('');
console.log('Benchmarking Run finished!');
console.log('');
console.log('Fastest function is: ' + this.filter('fastest').map('name'));
console.log('');
var stdin = process.openStdin();
var rl = readline.createInterface(process.stdin, process.stdout);
rl.setPrompt('Press Enter to rerun.');
rl.prompt();
rl.on('line', function (line) {
rl.close();
startSuite();
})
}
});
var functionNames = Object.keys(tests);
functionNames.forEach(function (functionName) {
suite.add(functionName, tests[functionName])
})
// run async
var startSuite = function() {
suite.run({ 'async': true });
}
startSuite();