-
-
Save floatdrop/a6939fc043a6a38e08fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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