-
Notifications
You must be signed in to change notification settings - Fork 1
/
bench.js
44 lines (34 loc) · 962 Bytes
/
bench.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
//@ts-check
const Benny = require('benny');
const fs = require('fs');
// All justReturns are exactly the same.
const { justReturn } = require('./dist/es2017');
const allTargets = fs.readdirSync('./dist');
Benny.suite(
'Return await tests',
...allTargets.flatMap((target) => {
const { doWait, dontWait } = require(`./dist/${target}`);
// Format name
// babel.js -> Babel
let name = target.replace('.js', '');
name = name.charAt(0).toUpperCase() + name.slice(1);
return [
Benny.add(`${name}: async () => await work()`, () => doWait()),
Benny.add(`${name}: () => await work()`, () => dontWait())
];
}),
// All justReturns are exactly the same.
Benny.add('() => work()', () => justReturn()),
Benny.cycle(),
Benny.complete(),
Benny.save({
folder: './results',
format: 'chart.html',
file: 'result'
}),
Benny.save({
folder: './results',
format: 'csv',
file: 'result'
})
);