-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy pathindex.js
More file actions
40 lines (30 loc) · 896 Bytes
/
index.js
File metadata and controls
40 lines (30 loc) · 896 Bytes
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
var Benchmark = require('benchmark'),
escodegen = require('../'),
old = require('./old.js'),
esotope = require('esotope'),
asts = require('./asts');
function cycle(codegen) {
for (var i = 0; i < asts.length; i++)
codegen.generate(asts[i]);
}
new Benchmark.Suite()
.add('esotope', function () {
cycle(esotope);
})
.add('escodegen', function () {
cycle(escodegen);
})
.add('old', function () {
cycle(old);
})
.on('start', function () {
console.log('Benchmarking...');
})
.on('cycle', function (event) {
console.log(event.target.toString());
})
.on('complete', function () {
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
console.log('esotope is x' + (this[0].hz / this[1].hz).toFixed(2) + ' times faster vs escodegen.');
})
.run();