],
"scripts": {
"test": "tape test/*.js",
- "perf": "browserify --debug perf/concat.js > perf/bundle.js && open perf/index.html"
+ "perf": "cd perf/solo && browserify --debug concat.js > bundle.js && open index.html"
},
"license": "MIT"
}
--- /dev/null
+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 = 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 })
var benchmark = require('benchmark')
var suite = new benchmark.Suite()
-global.NewBuffer = require('../').Buffer // native-buffer-browserify
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
var LENGTH = 16
var benchmark = require('benchmark')
var suite = new benchmark.Suite()
-global.NewBuffer = require('../').Buffer // native-buffer-browserify
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
var LENGTH = 10
var benchmark = require('benchmark')
var suite = new benchmark.Suite()
-global.NewBuffer = require('../').Buffer // native-buffer-browserify
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
var LENGTH = 10
var benchmark = require('benchmark')
var suite = new benchmark.Suite()
-global.NewBuffer = require('../').Buffer // native-buffer-browserify
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
var LENGTH = 10
var benchmark = require('benchmark')
var suite = new benchmark.Suite()
-global.NewBuffer = require('../').Buffer // native-buffer-browserify
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
var LENGTH = 10
var benchmark = require('benchmark')
var suite = new benchmark.Suite()
-global.NewBuffer = require('../').Buffer // native-buffer-browserify
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
var LENGTH = 20
var benchmark = require('benchmark')
var suite = new benchmark.Suite()
-global.NewBuffer = require('../').Buffer // native-buffer-browserify
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
var LENGTH = 16
var benchmark = require('benchmark')
var suite = new benchmark.Suite()
-global.NewBuffer = require('../').Buffer // native-buffer-browserify
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
global.OldBuffer = require('buffer-browserify').Buffer // buffer-browserify
var LENGTH = 10
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
+
+var LENGTH = 50
+
+var newTarget = NewBuffer(LENGTH)
+
+suite.add('NewBuffer#bracket-notation', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ newTarget[i] = i + 97
+ }
+})
+.on('error', function (event) {
+ console.error(event.target.error.stack)
+})
+.on('cycle', function (event) {
+ console.log(String(event.target))
+})
+
+.run({ 'async': true })
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
+
+var LENGTH = 16
+
+var newBuf = NewBuffer(LENGTH)
+var newBuf2 = NewBuffer(LENGTH)
+
+;[newBuf, newBuf2].forEach(function (buf) {
+ for (var i = 0; i < LENGTH; i++) {
+ buf[i] = 42
+ }
+})
+
+suite.add('NewBuffer#concat', function () {
+ var x = Buffer.concat([newBuf, newBuf2])
+})
+.on('error', function (event) {
+ console.error(event.target.error.stack)
+})
+.on('cycle', function (event) {
+ console.log(String(event.target))
+})
+
+.run({ 'async': true })
\ No newline at end of file
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
+
+var LENGTH = 10
+
+var newSubject = NewBuffer(LENGTH)
+var newTarget = NewBuffer(LENGTH)
+
+suite.add('NewBuffer#copy', function () {
+ newSubject.copy(newTarget)
+})
+.on('error', function (event) {
+ console.error(event.target.error.stack)
+})
+.on('cycle', function (event) {
+ console.log(String(event.target))
+})
+
+.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 // native-buffer-browserify
+
+var LENGTH = 10
+
+suite.add('NewBuffer#new', function () {
+ var buf = NewBuffer(LENGTH)
+})
+.add('Uint8Array#new', function () {
+ var buf = new Uint8Array(LENGTH)
+})
+.on('error', function (event) {
+ console.error(event.target.error.stack)
+})
+.on('cycle', function (event) {
+ console.log(String(event.target))
+})
+
+.run({ 'async': true })
\ No newline at end of file
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
+
+var LENGTH = 10
+
+var newTarget = NewBuffer(LENGTH * 8)
+
+for (var i = 0; i < LENGTH; i++) {
+ newTarget.writeDoubleBE(97.1919 + i, i * 8)
+}
+
+suite.add('NewBuffer#readDoubleBE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ var x = newTarget.readDoubleBE(i * 8)
+ }
+})
+.on('error', function (event) {
+ console.error(event.target.error.stack)
+})
+.on('cycle', function (event) {
+ console.log(String(event.target))
+})
+
+.run({ 'async': true })
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
+
+var LENGTH = 10
+
+var newTarget = NewBuffer(LENGTH * 4)
+
+for (var i = 0; i < LENGTH; i++) {
+ newTarget.writeFloatBE(97.1919 + i, i * 4)
+}
+
+suite.add('NewBuffer#readFloatBE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ var x = newTarget.readFloatBE(i * 4)
+ }
+})
+.on('error', function (event) {
+ console.error(event.target.error.stack)
+})
+.on('cycle', function (event) {
+ console.log(String(event.target))
+})
+
+.run({ 'async': true })
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
+
+var LENGTH = 20
+
+var newTarget = NewBuffer(LENGTH * 4)
+
+for (var i = 0; i < LENGTH; i++) {
+ newTarget.writeUInt32LE(7000 + i, i * 4)
+}
+
+suite.add('NewBuffer#readUInt32LE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ var x = newTarget.readUInt32LE(i * 4)
+ }
+})
+.on('error', function (event) {
+ console.error(event.target.error.stack)
+})
+.on('cycle', function (event) {
+ console.log(String(event.target))
+})
+
+.run({ 'async': true })
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
+
+var LENGTH = 16
+
+var newBuf = NewBuffer(LENGTH)
+
+suite.add('NewBuffer#slice', function () {
+ var x = newBuf.slice(4)
+})
+.on('error', function (event) {
+ console.error(event.target.error.stack)
+})
+.on('cycle', function (event) {
+ console.log(String(event.target))
+})
+
+.run({ 'async': true })
\ No newline at end of file
--- /dev/null
+var benchmark = require('benchmark')
+var suite = new benchmark.Suite()
+
+global.NewBuffer = require('../../').Buffer // native-buffer-browserify
+
+var LENGTH = 10
+
+var newTarget = NewBuffer(LENGTH * 4)
+
+suite.add('NewBuffer#writeFloatBE', function () {
+ for (var i = 0; i < LENGTH; i++) {
+ newTarget.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))
+})
+
+.run({ 'async': true })