--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../').Buffer // buffer-browserify-fast
+global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
+
+var LENGTH = 50
+
+var newTarget = NewBuffer(LENGTH)
+var oldTarget = OldBuffer(LENGTH)
+var nodeTarget = Buffer(LENGTH)
+
+suite.add('NewBuffer#bracket-notation', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ newTarget[i] = i + 97
+ }
+})
+.add('OldBuffer#bracket-notation', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ oldTarget[i] = i + 97
+ }
+})
+.add('Buffer#bracket-notation', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ nodeTarget[i] = i + 97
+ }
+})
+.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 })
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../').Buffer // buffer-browserify-fast
+global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
+
+var LENGTH = 16
+
+var newBuf = NewBuffer(LENGTH)
+var newBuf2 = NewBuffer(LENGTH)
+var oldBuf = OldBuffer(LENGTH)
+var oldBuf2 = OldBuffer(LENGTH)
+var nodeBuf = Buffer(LENGTH)
+var nodeBuf2 = Buffer(LENGTH)
+
+;[newBuf, newBuf2, oldBuf, oldBuf2, nodeBuf, nodeBuf2].forEach(function (buf) {
+ for (var i = 0; i < LENGTH; i++) {
+ buf[i] = 42
+ }
+})
+
+suite.add('NewBuffer#concat', function () {
+ var x = Buffer.concat([newBuf, newBuf2])
+})
+.add('OldBuffer#concat', function () {
+ var x = Buffer.concat([oldBuf, oldBuf2])
+})
+.add('Buffer#concat', function () {
+ var x = Buffer.concat([nodeBuf, nodeBuf2])
+})
+.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
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../').Buffer // buffer-browserify-fast
+global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
+
+var LENGTH = 10
+
+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
--- /dev/null
+<script src='bundle.js'></script>
\ No newline at end of file
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../').Buffer // buffer-browserify-fast
+global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
+
+var LENGTH = 10
+
+suite.add('NewBuffer#new', function () {
+ var buf = NewBuffer(LENGTH)
+})
+.add('Uint8Array#new', function () {
+ var buf = new Uint8Array(LENGTH)
+})
+.add('OldBuffer#new', function () {
+ var buf = OldBuffer(LENGTH)
+})
+.add('Buffer#new', function () {
+ var buf = Buffer(LENGTH)
+})
+.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
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../').Buffer // buffer-browserify-fast
+global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
+
+var LENGTH = 10
+
+var newTarget = NewBuffer(LENGTH * 8)
+var oldTarget = OldBuffer(LENGTH * 8)
+var nodeTarget = Buffer(LENGTH * 8)
+
+;[newTarget, oldTarget, nodeTarget].forEach(function (buf) {
+ for (var i = 0; i < LENGTH; i++) {
+ buf.writeDoubleBE(97.1919 + i, i * 8)
+ }
+})
+
+suite.add('NewBuffer#readDoubleBE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ var x = newTarget.readDoubleBE(i * 8)
+ }
+})
+.add('OldBuffer#readDoubleBE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ var x = oldTarget.readDoubleBE(i * 8)
+ }
+})
+.add('Buffer#readDoubleBE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ var x = nodeTarget.readDoubleBE(i * 8)
+ }
+})
+.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 })
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../').Buffer // buffer-browserify-fast
+global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
+
+var LENGTH = 10
+
+var newTarget = NewBuffer(LENGTH * 4)
+var oldTarget = OldBuffer(LENGTH * 4)
+var nodeTarget = Buffer(LENGTH * 4)
+
+;[newTarget, oldTarget, nodeTarget].forEach(function (buf) {
+ for (var i = 0; i < LENGTH; i++) {
+ buf.writeFloatBE(97.1919 + i, i * 4)
+ }
+})
+
+suite.add('NewBuffer#readFloatBE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ var x = newTarget.readFloatBE(i * 4)
+ }
+})
+.add('OldBuffer#readFloatBE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ var x = oldTarget.readFloatBE(i * 4)
+ }
+})
+.add('Buffer#readFloatBE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ var x = nodeTarget.readFloatBE(i * 4)
+ }
+})
+.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 })
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../').Buffer // buffer-browserify-fast
+global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
+
+var LENGTH = 20
+
+var newTarget = NewBuffer(LENGTH * 4)
+var oldTarget = OldBuffer(LENGTH * 4)
+var nodeTarget = Buffer(LENGTH * 4)
+
+;[newTarget, oldTarget, nodeTarget].forEach(function (buf) {
+ for (var i = 0; i < LENGTH; i++) {
+ buf.writeUInt32LE(7000 + i, i * 4)
+ }
+})
+
+suite.add('NewBuffer#readUInt32LE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ var x = newTarget.readUInt32LE(i * 4)
+ }
+})
+.add('OldBuffer#readUInt32LE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ var x = oldTarget.readUInt32LE(i * 4)
+ }
+})
+.add('Buffer#readUInt32LE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ var x = nodeTarget.readUInt32LE(i * 4)
+ }
+})
+.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 })
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../').Buffer // buffer-browserify-fast
+global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
+
+var LENGTH = 16
+
+var newBuf = NewBuffer(LENGTH)
+var oldBuf = OldBuffer(LENGTH)
+var nodeBuf = Buffer(LENGTH)
+
+suite.add('NewBuffer#slice', function () {
+ var x = newBuf.slice(4)
+})
+.add('OldBuffer#slice', function () {
+ var x = oldBuf.slice(4)
+})
+.add('Buffer#slice', function () {
+ var x = nodeBuf.slice(4)
+})
+.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
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../').Buffer // buffer-browserify-fast
+global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
+
+var LENGTH = 10
+
+var newTarget = NewBuffer(LENGTH * 4)
+var oldTarget = OldBuffer(LENGTH * 4)
+var nodeTarget = Buffer(LENGTH * 4)
+
+suite.add('NewBuffer#writeFloatBE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ newTarget.writeFloatBE(97.1919 + i, i * 4)
+ }
+})
+.add('OldBuffer#writeFloatBE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ oldTarget.writeFloatBE(97.1919 + i, i * 4)
+ }
+})
+.add('Buffer#writeFloatBE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ nodeTarget.writeFloatBE(97.1919 + i, i * 4)
+ }
+})
+.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 })