-
Notifications
You must be signed in to change notification settings - Fork 336
/
Copy pathindex.js
39 lines (30 loc) · 908 Bytes
/
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
import Benchmark from 'benchmark';
import esotope from 'esotope';
import * as escodegen from '../src/escodegen-node.js';
import old from './old.cjs';
import asts from './asts.js';
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').map('name')}`);
console.log('esotope is x' + (this[0].hz / this[1].hz).toFixed(2) + ' times faster vs escodegen.');
})
.run();