Created
March 28, 2016 12:46
-
-
Save akira-cn/317bc6c2e526b62bc808 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
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