Skip to content

Instantly share code, notes, and snippets.

@trevnorris
Last active August 29, 2015 14:27
Show Gist options
  • Save trevnorris/efe36274b0d0a23a78f5 to your computer and use it in GitHub Desktop.
Save trevnorris/efe36274b0d0a23a78f5 to your computer and use it in GitHub Desktop.
'use strict';
const SlowBuffer = require('buffer').SlowBuffer;
const ITER = 1e7;
const SIZE = 65536;
let t = process.hrtime()
for (let i = 0; i < ITER; i++) {
new SlowBuffer(SIZE);
}
t = process.hrtime(t);
console.log(((t[0] * 1e9 + t[1]) / ITER).toFixed(1) + ' ns/op');
/**
* Benchmark Results SlowBuffer
*
* node 0.12.7
*
* SIZE TIME
* 1 466
* 256 653
* 1024 811
* 4096 919
* 16384 985
* 65536 1266
* 262144 2814
*
* iojs 2.5.0
*
* SIZE TIME
* 1 463
* 256 636
* 1024 750
* 4096 885
* 16384 1087
* 65536 1778
* 262144 4930
*
* iojs 3.1.0
*
* SIZE TIME
* 1 1038
* 256 1090
* 1024 1214
* 4096 1706
* 16384 1937
* 65536 3132
* 262144 6146
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment