From adf798890c2096497762f5374e04a38f644bcb30 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Sat, 5 Apr 2014 20:12:43 +0200 Subject: [PATCH] add bench for 10k copy --- perf/comparison/copy-big.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 perf/comparison/copy-big.js 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 -- 2.34.1