Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
var str_long = (new Array(50000)).join('0');
var str_mid = (new Array(500)).join('0');
var str_short = (new Array(5)).join('0');
suite.add('concat#longstr', function() {
str_long + str_long;
})
.add('concat#mid', function() {
str_mid + str_mid;
})
.add('concat#shortstr', function() {
str_short + str_short;
})
// add listeners
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
// run async
.run({ 'async': true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.