Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const Benchmark = require('benchmark');
var bench = Benchmark({
fn : function(){
var a = new Buffer(1024);
}
});
console.log(String(bench.run()));
// $ ./node benchmark.js
// <Test #1> x 1,196,283 ops/sec ±1.27% (80 runs sampled)
// $ node benchmark.js
// <Test #1> x 1,234,358 ops/sec ±1.67% (76 runs sampled)
// $ ./node benchmark/common.js buffers
buffers/buffer-creation.js
buffers/buffer-creation.js type=fast len=10 n=1024: 3623.97512
buffers/buffer-creation.js type=fast len=1024 n=1024: 1188.15860
buffers/buffer-creation.js type=slow len=10 n=1024: 1128.48789
buffers/buffer-creation.js type=slow len=1024 n=1024: 955.14037
// $ node benchmark/common.js buffers
buffers/buffer-creation.js
buffers/buffer-creation.js type=fast len=10 n=1024: 2818.92383
buffers/buffer-creation.js type=fast len=1024 n=1024: 1313.60635
buffers/buffer-creation.js type=slow len=10 n=1024: 966.95189
buffers/buffer-creation.js type=slow len=1024 n=1024: 891.08745
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment