Skip to content

Instantly share code, notes, and snippets.

@floatdrop
Created July 31, 2014 06:07
Show Gist options
  • Save floatdrop/a6939fc043a6a38e08fc to your computer and use it in GitHub Desktop.
Save floatdrop/a6939fc043a6a38e08fc to your computer and use it in GitHub Desktop.
// npm i benchmark beautify-benchmark bh bemer
// node benchmark.js
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite();
var benchmarks = require('beautify-benchmark');
var BH = require('bh').BH;
var bh = new BH();
var bemer = require('bemer');
function construct(obj, depth) {
if (depth < 5) {
obj.content = [
construct({ block: 'block' }, depth + 1),
construct({ block: 'block' }, depth + 1),
construct({ block: 'block' }, depth + 1)
];
}
return obj;
}
suite
.add('bemer#block', function() {
bemer(
construct({ block: 'block' }, 0)
);
})
.add('bh#block', function() {
bh.apply(
construct({ block: 'block' }, 0)
);
})
.on('cycle', function(event) { benchmarks.add(event.target); })
.on('complete', function() { benchmarks.log(); })
.run({ 'async': true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment