/
index.js
49 lines (41 loc) · 1.08 KB
/
index.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
'use strict';
const async = require('async');
const Benchmark = require('benchmark');
const benchpress = require('../../build/lib/benchpress');
const categories = require('./categories');
const topic = require('./topic');
const compilation = require('./compilation');
Benchmark.options.defer = true;
Benchmark.options.minSamples = 100;
const suite = new Benchmark.Suite();
function benchmark(done) {
async.parallel([
categories,
topic,
compilation,
], (err, [cats, top, comp]) => {
const cache = {
categories: cats.template,
topic: top.template,
};
benchpress.registerLoader((name, callback) => {
callback(cache[name]);
});
const output = [];
suite
.add('categories', cats.bench)
.add('topic', top.bench)
.add('compilation', comp.bench)
.add('native compilation', comp.benchNative)
.on('cycle', (event) => {
output.push(event.target.toString());
})
.on('complete', () => {
done(null, output);
})
.run({
async: true,
});
});
}
module.exports = benchmark;