Last active
October 9, 2015 02:45
-
-
Save shuhei/1378d04ec050e8646720 to your computer and use it in GitHub Desktop.
Buffer#toString on Node 0.12.7
This file contains hidden or 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(); | |
suite.add('Buffer#toString 1MB', function () { | |
new Buffer(1000 * 1000).toString(); | |
}) | |
.add('Buffer#toString 100KB', function () { | |
new Buffer(100 * 1000).toString(); | |
}) | |
.on('cycle', function (event) { | |
console.log(String(event.target)); | |
}) | |
.on('complete', function () { | |
console.log('Fastest is ' + this.filter('fastest').pluck('name')); | |
}) | |
.run({ async: true }); |
This file contains hidden or 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
# Machine: MBP Retina Mid 2013, CPU: 2.3 GHz Intel Core i7, Memory: 8GB | |
$ node -v | |
v0.12.7 | |
$ node buffer.js | |
Buffer#toString 1MB x 1,750 ops/sec ±52.42% (36 runs sampled) | |
Buffer#toString 100KB x 3,450 ops/sec ±3.02% (59 runs sampled) | |
Fastest is Buffer#toString 100KB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment