From: Mathias Buus Date: Sat, 5 Apr 2014 18:12:43 +0000 (+0200) Subject: add bench for 10k copy X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=adf798890c2096497762f5374e04a38f644bcb30;p=buffer.git add bench for 10k copy --- diff --git a/perf/comparison/copy-big.js b/perf/comparison/copy-big.js new file mode 100644 index 0000000..8d355d8 --- /dev/null +++ b/perf/comparison/copy-big.js @@ -0,0 +1,35 @@ +var benchmark = require('benchmark') +var suite = new benchmark.Suite() + +global.NewBuffer = require('../../').Buffer // native-buffer-browserify +global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify + +var LENGTH = 10000 + +var newSubject = NewBuffer(LENGTH) +var oldSubject = OldBuffer(LENGTH) +var nodeSubject = Buffer(LENGTH) + +var newTarget = NewBuffer(LENGTH) +var oldTarget = OldBuffer(LENGTH) +var nodeTarget = Buffer(LENGTH) + +suite.add('NewBuffer#copy', function () { + newSubject.copy(newTarget) +}) +.add('OldBuffer#copy', function () { + oldSubject.copy(oldTarget) +}) +.add('Buffer#copy', function () { + nodeSubject.copy(nodeTarget) +}) +.on('error', function (event) { + console.error(event.target.error.stack) +}) +.on('cycle', function (event) { + console.log(String(event.target)) +}) +.on('complete', function () { + console.log('Fastest is ' + this.filter('fastest').pluck('name')) +}) +.run({ 'async': true }) \ No newline at end of file