]> zoso.dev Git - buffer.git/commitdiff
add bench for 10k copy
authorMathias Buus <mathiasbuus@gmail.com>
Sat, 5 Apr 2014 18:12:43 +0000 (20:12 +0200)
committerMathias Buus <mathiasbuus@gmail.com>
Sat, 5 Apr 2014 18:24:06 +0000 (20:24 +0200)
perf/comparison/copy-big.js [new file with mode: 0644]

diff --git a/perf/comparison/copy-big.js b/perf/comparison/copy-big.js
new file mode 100644 (file)
index 0000000..8d355d8
--- /dev/null
@@ -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