summaryrefslogtreecommitdiff
path: root/deps/node/benchmark/buffers
diff options
context:
space:
mode:
Diffstat (limited to 'deps/node/benchmark/buffers')
-rw-r--r--deps/node/benchmark/buffers/buffer-base64-decode-wrapped.js25
-rw-r--r--deps/node/benchmark/buffers/buffer-base64-decode.js20
-rw-r--r--deps/node/benchmark/buffers/buffer-base64-encode.js39
-rw-r--r--deps/node/benchmark/buffers/buffer-bytelength.js49
-rw-r--r--deps/node/benchmark/buffers/buffer-compare-instance-method.js76
-rw-r--r--deps/node/benchmark/buffers/buffer-compare-offset.js28
-rw-r--r--deps/node/benchmark/buffers/buffer-compare.js41
-rw-r--r--deps/node/benchmark/buffers/buffer-concat.js22
-rw-r--r--deps/node/benchmark/buffers/buffer-creation.js53
-rw-r--r--deps/node/benchmark/buffers/buffer-fill.js31
-rw-r--r--deps/node/benchmark/buffers/buffer-from.js98
-rw-r--r--deps/node/benchmark/buffers/buffer-hex.js25
-rw-r--r--deps/node/benchmark/buffers/buffer-indexof-number.js21
-rw-r--r--deps/node/benchmark/buffers/buffer-indexof.js53
-rw-r--r--deps/node/benchmark/buffers/buffer-iterate.js57
-rw-r--r--deps/node/benchmark/buffers/buffer-normalize-encoding.js43
-rw-r--r--deps/node/benchmark/buffers/buffer-read-float.js39
-rw-r--r--deps/node/benchmark/buffers/buffer-read-with-byteLength.js29
-rw-r--r--deps/node/benchmark/buffers/buffer-read.js39
-rw-r--r--deps/node/benchmark/buffers/buffer-slice.js20
-rw-r--r--deps/node/benchmark/buffers/buffer-swap.js83
-rw-r--r--deps/node/benchmark/buffers/buffer-tojson.js17
-rw-r--r--deps/node/benchmark/buffers/buffer-tostring.js45
-rw-r--r--deps/node/benchmark/buffers/buffer-write-string.js65
-rw-r--r--deps/node/benchmark/buffers/buffer-write.js101
-rw-r--r--deps/node/benchmark/buffers/buffer-zero.js19
-rw-r--r--deps/node/benchmark/buffers/dataview-set.js72
27 files changed, 0 insertions, 1210 deletions
diff --git a/deps/node/benchmark/buffers/buffer-base64-decode-wrapped.js b/deps/node/benchmark/buffers/buffer-base64-decode-wrapped.js
deleted file mode 100644
index 7aee5a89..00000000
--- a/deps/node/benchmark/buffers/buffer-base64-decode-wrapped.js
+++ /dev/null
@@ -1,25 +0,0 @@
-'use strict';
-
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- charsPerLine: [76],
- linesCount: [8 << 16],
- n: [32],
-});
-
-function main({ charsPerLine, linesCount, n }) {
- const bytesCount = charsPerLine * linesCount / 4 * 3;
-
- const line = `${'abcd'.repeat(charsPerLine / 4)}\n`;
- const data = line.repeat(linesCount);
- // eslint-disable-next-line node-core/no-unescaped-regexp-dot
- data.match(/./); // Flatten the string
- const buffer = Buffer.alloc(bytesCount, line, 'base64');
-
- bench.start();
- for (var i = 0; i < n; i++) {
- buffer.base64Write(data, 0, bytesCount);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-base64-decode.js b/deps/node/benchmark/buffers/buffer-base64-decode.js
deleted file mode 100644
index 0ac694fe..00000000
--- a/deps/node/benchmark/buffers/buffer-base64-decode.js
+++ /dev/null
@@ -1,20 +0,0 @@
-'use strict';
-const assert = require('assert');
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- n: [32],
- size: [8 << 20]
-});
-
-function main({ n, size }) {
- const s = 'abcd'.repeat(size);
- // eslint-disable-next-line node-core/no-unescaped-regexp-dot
- s.match(/./); // Flatten string.
- assert.strictEqual(s.length % 4, 0);
- const b = Buffer.allocUnsafe(s.length / 4 * 3);
- b.write(s, 0, s.length, 'base64');
- bench.start();
- for (var i = 0; i < n; i += 1) b.base64Write(s, 0, s.length);
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-base64-encode.js b/deps/node/benchmark/buffers/buffer-base64-encode.js
deleted file mode 100644
index d8b601bb..00000000
--- a/deps/node/benchmark/buffers/buffer-base64-encode.js
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-'use strict';
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- len: [64 * 1024 * 1024],
- n: [32]
-});
-
-function main({ n, len }) {
- const b = Buffer.allocUnsafe(len);
- let s = '';
- let i;
- for (i = 0; i < 256; ++i) s += String.fromCharCode(i);
- for (i = 0; i < len; i += 256) b.write(s, i, 256, 'ascii');
- bench.start();
- for (i = 0; i < n; ++i) b.toString('base64');
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-bytelength.js b/deps/node/benchmark/buffers/buffer-bytelength.js
deleted file mode 100644
index 4caad301..00000000
--- a/deps/node/benchmark/buffers/buffer-bytelength.js
+++ /dev/null
@@ -1,49 +0,0 @@
-'use strict';
-const common = require('../common');
-
-const bench = common.createBenchmark(main, {
- encoding: ['utf8', 'base64', 'buffer'],
- len: [1, 2, 4, 16, 64, 256], // x16
- n: [5e6]
-});
-
-// 16 chars each
-const chars = [
- 'hello brendan!!!', // 1 byte
- 'ΰαβγδεζηθικλμνξο', // 2 bytes
- '挰挱挲挳挴挵挶挷挸挹挺挻挼挽挾挿', // 3 bytes
- '𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢', // 4 bytes
-];
-
-function main({ n, len, encoding }) {
- var strings = [];
- var results = [ len * 16 ];
- if (encoding === 'buffer') {
- strings = [ Buffer.alloc(len * 16, 'a') ];
- } else {
- for (const string of chars) {
- // Strings must be built differently, depending on encoding
- const data = string.repeat(len);
- if (encoding === 'utf8') {
- strings.push(data);
- } else if (encoding === 'base64') {
- // Base64 strings will be much longer than their UTF8 counterparts
- strings.push(Buffer.from(data, 'utf8').toString('base64'));
- }
- }
-
- // Check the result to ensure it is *properly* optimized
- results = strings.map((val) => Buffer.byteLength(val, encoding));
- }
-
- bench.start();
- for (var i = 0; i < n; i++) {
- const index = n % strings.length;
- // Go!
- const r = Buffer.byteLength(strings[index], encoding);
-
- if (r !== results[index])
- throw new Error('incorrect return value');
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-compare-instance-method.js b/deps/node/benchmark/buffers/buffer-compare-instance-method.js
deleted file mode 100644
index 77a3e84f..00000000
--- a/deps/node/benchmark/buffers/buffer-compare-instance-method.js
+++ /dev/null
@@ -1,76 +0,0 @@
-'use strict';
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- size: [16, 512, 1024, 4096, 16386],
- args: [1, 2, 3, 4, 5],
- n: [1e6]
-});
-
-function main({ n, size, args }) {
- const b0 = Buffer.alloc(size, 'a');
- const b1 = Buffer.alloc(size, 'a');
- const b0Len = b0.length;
- const b1Len = b1.length;
- var i;
-
- b1[size - 1] = 'b'.charCodeAt(0);
-
- switch (args) {
- case 2:
- b0.compare(b1, 0);
- break;
- case 3:
- b0.compare(b1, 0, b1Len);
- break;
- case 4:
- b0.compare(b1, 0, b1Len, 0);
- break;
- case 5:
- b0.compare(b1, 0, b1Len, 0, b0Len);
- break;
- default:
- b0.compare(b1);
- }
- switch (args) {
- case 2:
- b0.compare(b1, 0);
- bench.start();
- for (i = 0; i < n; i++) {
- b0.compare(b1, 0);
- }
- bench.end(n);
- break;
- case 3:
- b0.compare(b1, 0, b1Len);
- bench.start();
- for (i = 0; i < n; i++) {
- b0.compare(b1, 0, b1Len);
- }
- bench.end(n);
- break;
- case 4:
- b0.compare(b1, 0, b1Len, 0);
- bench.start();
- for (i = 0; i < n; i++) {
- b0.compare(b1, 0, b1Len, 0);
- }
- bench.end(n);
- break;
- case 5:
- b0.compare(b1, 0, b1Len, 0, b0Len);
- bench.start();
- for (i = 0; i < n; i++) {
- b0.compare(b1, 0, b1Len, 0, b0Len);
- }
- bench.end(n);
- break;
- default:
- b0.compare(b1);
- bench.start();
- for (i = 0; i < n; i++) {
- b0.compare(b1);
- }
- bench.end(n);
- }
-}
diff --git a/deps/node/benchmark/buffers/buffer-compare-offset.js b/deps/node/benchmark/buffers/buffer-compare-offset.js
deleted file mode 100644
index 89cc4427..00000000
--- a/deps/node/benchmark/buffers/buffer-compare-offset.js
+++ /dev/null
@@ -1,28 +0,0 @@
-'use strict';
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- method: ['offset', 'slice'],
- size: [16, 512, 1024, 4096, 16386],
- n: [1e6]
-});
-
-function compareUsingSlice(b0, b1, len, iter) {
- for (var i = 0; i < iter; i++)
- Buffer.compare(b0.slice(1, len), b1.slice(1, len));
-}
-
-function compareUsingOffset(b0, b1, len, iter) {
- for (var i = 0; i < iter; i++)
- b0.compare(b1, 1, len, 1, len);
-}
-
-function main({ n, size, method }) {
- const fn = method === 'slice' ? compareUsingSlice : compareUsingOffset;
- bench.start();
- fn(Buffer.alloc(size, 'a'),
- Buffer.alloc(size, 'b'),
- size >> 1,
- n);
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-compare.js b/deps/node/benchmark/buffers/buffer-compare.js
deleted file mode 100644
index cb4f0f47..00000000
--- a/deps/node/benchmark/buffers/buffer-compare.js
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-'use strict';
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- size: [16, 512, 1024, 4096, 16386],
- n: [1e6]
-});
-
-function main({ n, size }) {
- const b0 = Buffer.alloc(size, 'a');
- const b1 = Buffer.alloc(size, 'a');
-
- b1[size - 1] = 'b'.charCodeAt(0);
-
- bench.start();
- for (var i = 0; i < n; i++) {
- Buffer.compare(b0, b1);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-concat.js b/deps/node/benchmark/buffers/buffer-concat.js
deleted file mode 100644
index 3f9cffc0..00000000
--- a/deps/node/benchmark/buffers/buffer-concat.js
+++ /dev/null
@@ -1,22 +0,0 @@
-'use strict';
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- pieces: [1, 4, 16],
- pieceSize: [1, 16, 256],
- withTotalLength: [0, 1],
- n: [1024]
-});
-
-function main({ n, pieces, pieceSize, withTotalLength }) {
- const list = new Array(pieces);
- list.fill(Buffer.allocUnsafe(pieceSize));
-
- const totalLength = withTotalLength ? pieces * pieceSize : undefined;
-
- bench.start();
- for (var i = 0; i < n * 1024; i++) {
- Buffer.concat(list, totalLength);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-creation.js b/deps/node/benchmark/buffers/buffer-creation.js
deleted file mode 100644
index a7b34013..00000000
--- a/deps/node/benchmark/buffers/buffer-creation.js
+++ /dev/null
@@ -1,53 +0,0 @@
-'use strict';
-const SlowBuffer = require('buffer').SlowBuffer;
-
-const common = require('../common.js');
-const assert = require('assert');
-const bench = common.createBenchmark(main, {
- type: [
- 'fast-alloc',
- 'fast-alloc-fill',
- 'fast-allocUnsafe',
- 'slow-allocUnsafe',
- 'slow',
- 'buffer()'],
- len: [10, 1024, 2048, 4096, 8192],
- n: [1024]
-});
-
-function main({ len, n, type }) {
- let fn, i;
- switch (type) {
- case '':
- case 'fast-alloc':
- fn = Buffer.alloc;
- break;
- case 'fast-alloc-fill':
- bench.start();
- for (i = 0; i < n * 1024; i++) {
- Buffer.alloc(len, 0);
- }
- bench.end(n);
- return;
- case 'fast-allocUnsafe':
- fn = Buffer.allocUnsafe;
- break;
- case 'slow-allocUnsafe':
- fn = Buffer.allocUnsafeSlow;
- break;
- case 'slow':
- fn = SlowBuffer;
- break;
- case 'buffer()':
- fn = Buffer;
- break;
- default:
- assert.fail('Should not get here');
- }
-
- bench.start();
- for (i = 0; i < n * 1024; i++) {
- fn(len);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-fill.js b/deps/node/benchmark/buffers/buffer-fill.js
deleted file mode 100644
index b497597f..00000000
--- a/deps/node/benchmark/buffers/buffer-fill.js
+++ /dev/null
@@ -1,31 +0,0 @@
-'use strict';
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- type: [
- 'fill(0)',
- 'fill("")',
- 'fill(100)',
- 'fill(400)',
- 'fill("t")',
- 'fill("test")',
- 'fill("t", "utf8")',
- 'fill("t", 0, "utf8")',
- 'fill("t", 0)',
- 'fill(Buffer.alloc(1), 0)',
- ],
- size: [2 ** 8, 2 ** 13, 2 ** 16],
- n: [2e4]
-});
-
-function main({ n, type, size }) {
- const buffer = Buffer.allocUnsafe(size);
- const testFunction = new Function('b', `
- for (var i = 0; i < ${n}; i++) {
- b.${type || 'fill(0)'};
- }
- `);
- bench.start();
- testFunction(buffer);
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-from.js b/deps/node/benchmark/buffers/buffer-from.js
deleted file mode 100644
index 437bf930..00000000
--- a/deps/node/benchmark/buffers/buffer-from.js
+++ /dev/null
@@ -1,98 +0,0 @@
-'use strict';
-
-const common = require('../common.js');
-const assert = require('assert');
-const bench = common.createBenchmark(main, {
- source: [
- 'array',
- 'arraybuffer',
- 'arraybuffer-middle',
- 'buffer',
- 'uint8array',
- 'string',
- 'string-utf8',
- 'string-base64',
- 'object',
- ],
- len: [10, 2048],
- n: [2048]
-});
-
-function main({ len, n, source }) {
- const array = new Array(len).fill(42);
- const arrayBuf = new ArrayBuffer(len);
- const str = 'a'.repeat(len);
- const buffer = Buffer.allocUnsafe(len);
- const uint8array = new Uint8Array(len);
- const obj = { length: null }; // Results in a new, empty Buffer
-
- switch (source) {
- case 'array':
- bench.start();
- for (let i = 0; i < n * 1024; i++) {
- Buffer.from(array);
- }
- bench.end(n);
- break;
- case 'arraybuffer':
- bench.start();
- for (let i = 0; i < n * 1024; i++) {
- Buffer.from(arrayBuf);
- }
- bench.end(n);
- break;
- case 'arraybuffer-middle':
- const offset = ~~(len / 4);
- const length = ~~(len / 2);
- bench.start();
- for (let i = 0; i < n * 1024; i++) {
- Buffer.from(arrayBuf, offset, length);
- }
- bench.end(n);
- break;
- case 'buffer':
- bench.start();
- for (let i = 0; i < n * 1024; i++) {
- Buffer.from(buffer);
- }
- bench.end(n);
- break;
- case 'uint8array':
- bench.start();
- for (let i = 0; i < n * 1024; i++) {
- Buffer.from(uint8array);
- }
- bench.end(n);
- break;
- case 'string':
- bench.start();
- for (let i = 0; i < n * 1024; i++) {
- Buffer.from(str);
- }
- bench.end(n);
- break;
- case 'string-utf8':
- bench.start();
- for (let i = 0; i < n * 1024; i++) {
- Buffer.from(str, 'utf8');
- }
- bench.end(n);
- break;
- case 'string-base64':
- bench.start();
- for (let i = 0; i < n * 1024; i++) {
- Buffer.from(str, 'base64');
- }
- bench.end(n);
- break;
- case 'object':
- bench.start();
- for (let i = 0; i < n * 1024; i++) {
- Buffer.from(obj);
- }
- bench.end(n);
- break;
- default:
- assert.fail('Should not get here');
- }
-}
diff --git a/deps/node/benchmark/buffers/buffer-hex.js b/deps/node/benchmark/buffers/buffer-hex.js
deleted file mode 100644
index 4d873139..00000000
--- a/deps/node/benchmark/buffers/buffer-hex.js
+++ /dev/null
@@ -1,25 +0,0 @@
-'use strict';
-
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- len: [0, 1, 64, 1024],
- n: [1e7]
-});
-
-function main({ len, n }) {
- const buf = Buffer.alloc(len);
- var i;
-
- for (i = 0; i < buf.length; i++)
- buf[i] = i & 0xff;
-
- const hex = buf.toString('hex');
-
- bench.start();
-
- for (i = 0; i < n; i += 1)
- Buffer.from(hex, 'hex');
-
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-indexof-number.js b/deps/node/benchmark/buffers/buffer-indexof-number.js
deleted file mode 100644
index 91bff0d5..00000000
--- a/deps/node/benchmark/buffers/buffer-indexof-number.js
+++ /dev/null
@@ -1,21 +0,0 @@
-'use strict';
-const common = require('../common.js');
-const fs = require('fs');
-const path = require('path');
-
-const bench = common.createBenchmark(main, {
- value: ['@'.charCodeAt(0)],
- n: [1e7]
-});
-
-function main({ n, value }) {
- const aliceBuffer = fs.readFileSync(
- path.resolve(__dirname, '../fixtures/alice.html')
- );
-
- bench.start();
- for (var i = 0; i < n; i++) {
- aliceBuffer.indexOf(value, 0, undefined);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-indexof.js b/deps/node/benchmark/buffers/buffer-indexof.js
deleted file mode 100644
index f3b9dcf1..00000000
--- a/deps/node/benchmark/buffers/buffer-indexof.js
+++ /dev/null
@@ -1,53 +0,0 @@
-'use strict';
-const common = require('../common.js');
-const fs = require('fs');
-const path = require('path');
-
-const searchStrings = [
- '@',
- 'SQ',
- '10x',
- '--l',
- 'Alice',
- 'Gryphon',
- 'Panther',
- 'Ou est ma chatte?',
- 'found it very',
- 'among mad people',
- 'neighbouring pool',
- 'Soo--oop',
- 'aaaaaaaaaaaaaaaaa',
- 'venture to go near the house till she had brought herself down to',
- '</i> to the Caterpillar',
-];
-
-const bench = common.createBenchmark(main, {
- search: searchStrings,
- encoding: ['undefined', 'utf8', 'ucs2', 'binary'],
- type: ['buffer', 'string'],
- n: [100000]
-});
-
-function main({ n, search, encoding, type }) {
- var aliceBuffer = fs.readFileSync(
- path.resolve(__dirname, '../fixtures/alice.html')
- );
-
- if (encoding === 'undefined') {
- encoding = undefined;
- }
-
- if (encoding === 'ucs2') {
- aliceBuffer = Buffer.from(aliceBuffer.toString(), encoding);
- }
-
- if (type === 'buffer') {
- search = Buffer.from(Buffer.from(search).toString(), encoding);
- }
-
- bench.start();
- for (var i = 0; i < n; i++) {
- aliceBuffer.indexOf(search, 0, encoding);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-iterate.js b/deps/node/benchmark/buffers/buffer-iterate.js
deleted file mode 100644
index 7a275b0b..00000000
--- a/deps/node/benchmark/buffers/buffer-iterate.js
+++ /dev/null
@@ -1,57 +0,0 @@
-'use strict';
-const SlowBuffer = require('buffer').SlowBuffer;
-const common = require('../common.js');
-const assert = require('assert');
-
-const bench = common.createBenchmark(main, {
- size: [16, 512, 1024, 4096, 16386],
- type: ['fast', 'slow'],
- method: ['for', 'forOf', 'iterator'],
- n: [1e3]
-});
-
-const methods = {
- 'for': benchFor,
- 'forOf': benchForOf,
- 'iterator': benchIterator
-};
-
-function main({ size, type, method, n }) {
- const clazz = type === 'fast' ? Buffer : SlowBuffer;
- const buffer = new clazz(size);
- buffer.fill(0);
- const fn = methods[method || 'for'];
-
- bench.start();
- fn(buffer, n);
- bench.end(n);
-}
-
-function benchFor(buffer, n) {
- for (var k = 0; k < n; k++) {
- for (var i = 0; i < buffer.length; i++) {
- assert(buffer[i] === 0);
- }
- }
-}
-
-function benchForOf(buffer, n) {
- for (var k = 0; k < n; k++) {
- for (const b of buffer) {
- assert(b === 0);
- }
- }
-}
-
-function benchIterator(buffer, n) {
- for (var k = 0; k < n; k++) {
- const iter = buffer[Symbol.iterator]();
- var cur = iter.next();
-
- while (!cur.done) {
- assert(cur.value === 0);
- cur = iter.next();
- }
-
- }
-}
diff --git a/deps/node/benchmark/buffers/buffer-normalize-encoding.js b/deps/node/benchmark/buffers/buffer-normalize-encoding.js
deleted file mode 100644
index e33f7e0b..00000000
--- a/deps/node/benchmark/buffers/buffer-normalize-encoding.js
+++ /dev/null
@@ -1,43 +0,0 @@
-'use strict';
-
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- encoding: [
- 'ascii',
- 'ASCII',
- 'base64',
- 'BASE64',
- 'binary',
- 'BINARY',
- 'hex',
- 'HEX',
- 'latin1',
- 'LATIN1',
- 'ucs-2',
- 'UCS-2',
- 'ucs2',
- 'UCS2',
- 'utf-16le',
- 'UTF-16LE',
- 'utf-8',
- 'UTF-8',
- 'utf16le',
- 'UTF16LE',
- 'utf8',
- 'UTF8',
- ],
- n: [1e6]
-}, {
- flags: ['--expose-internals']
-});
-
-function main({ encoding, n }) {
- const { normalizeEncoding } = require('internal/util');
-
- bench.start();
- for (var i = 0; i < n; i++) {
- normalizeEncoding(encoding);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-read-float.js b/deps/node/benchmark/buffers/buffer-read-float.js
deleted file mode 100644
index dbccf573..00000000
--- a/deps/node/benchmark/buffers/buffer-read-float.js
+++ /dev/null
@@ -1,39 +0,0 @@
-'use strict';
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- type: ['Double', 'Float'],
- endian: ['BE', 'LE'],
- value: ['zero', 'big', 'small', 'inf', 'nan'],
- n: [1e6]
-});
-
-function main({ n, type, endian, value }) {
- type = type || 'Double';
- const buff = Buffer.alloc(8);
- const fn = `read${type}${endian}`;
- const values = {
- Double: {
- zero: 0,
- big: 2 ** 1023,
- small: 2 ** -1074,
- inf: Infinity,
- nan: NaN,
- },
- Float: {
- zero: 0,
- big: 2 ** 127,
- small: 2 ** -149,
- inf: Infinity,
- nan: NaN,
- },
- };
-
- buff[`write${type}${endian}`](values[type][value], 0);
-
- bench.start();
- for (var i = 0; i !== n; i++) {
- buff[fn](0);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-read-with-byteLength.js b/deps/node/benchmark/buffers/buffer-read-with-byteLength.js
deleted file mode 100644
index 65d5f8f0..00000000
--- a/deps/node/benchmark/buffers/buffer-read-with-byteLength.js
+++ /dev/null
@@ -1,29 +0,0 @@
-'use strict';
-const common = require('../common.js');
-
-const types = [
- 'IntBE',
- 'IntLE',
- 'UIntBE',
- 'UIntLE',
-];
-
-const bench = common.createBenchmark(main, {
- buffer: ['fast', 'slow'],
- type: types,
- n: [1e6],
- byteLength: [1, 2, 3, 4, 5, 6]
-});
-
-function main({ n, buf, type, byteLength }) {
- const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer;
- const buff = new clazz(8);
- const fn = `read${type || 'IntBE'}`;
-
- buff.writeDoubleLE(0, 0);
- bench.start();
- for (var i = 0; i !== n; i++) {
- buff[fn](0, byteLength);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-read.js b/deps/node/benchmark/buffers/buffer-read.js
deleted file mode 100644
index 38a9a847..00000000
--- a/deps/node/benchmark/buffers/buffer-read.js
+++ /dev/null
@@ -1,39 +0,0 @@
-'use strict';
-const common = require('../common.js');
-
-const types = [
- 'UInt8',
- 'UInt16LE',
- 'UInt16BE',
- 'UInt32LE',
- 'UInt32BE',
- 'Int8',
- 'Int16LE',
- 'Int16BE',
- 'Int32LE',
- 'Int32BE',
- 'FloatLE',
- 'FloatBE',
- 'DoubleLE',
- 'DoubleBE',
-];
-
-const bench = common.createBenchmark(main, {
- buffer: ['fast', 'slow'],
- type: types,
- n: [1e6]
-});
-
-function main({ n, buf, type }) {
- const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer;
- const buff = new clazz(8);
- const fn = `read${type || 'UInt8'}`;
-
- buff.writeDoubleLE(0, 0);
- bench.start();
-
- for (var i = 0; i !== n; i++) {
- buff[fn](0);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-slice.js b/deps/node/benchmark/buffers/buffer-slice.js
deleted file mode 100644
index 2e52475d..00000000
--- a/deps/node/benchmark/buffers/buffer-slice.js
+++ /dev/null
@@ -1,20 +0,0 @@
-'use strict';
-const common = require('../common.js');
-const SlowBuffer = require('buffer').SlowBuffer;
-
-const bench = common.createBenchmark(main, {
- type: ['fast', 'slow'],
- n: [1024]
-});
-
-const buf = Buffer.allocUnsafe(1024);
-const slowBuf = new SlowBuffer(1024);
-
-function main({ n, type }) {
- const b = type === 'fast' ? buf : slowBuf;
- bench.start();
- for (var i = 0; i < n * 1024; i++) {
- b.slice(10, 256);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-swap.js b/deps/node/benchmark/buffers/buffer-swap.js
deleted file mode 100644
index a85bcf32..00000000
--- a/deps/node/benchmark/buffers/buffer-swap.js
+++ /dev/null
@@ -1,83 +0,0 @@
-'use strict';
-
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- aligned: ['true', 'false'],
- method: ['swap16', 'swap32', 'swap64'/* , 'htons', 'htonl', 'htonll' */],
- len: [8, 64, 128, 256, 512, 768, 1024, 1536, 2056, 4096, 8192],
- n: [5e7]
-});
-
-// The htons and htonl methods below are used to benchmark the
-// performance difference between doing the byteswap in pure
-// javascript regardless of Buffer size as opposed to dropping
-// down to the native layer for larger Buffer sizes. Commented
-// out by default because they are slow for big buffers. If
-// re-evaluating the crossover point, uncomment those methods
-// and comment out their implementations in lib/buffer.js so
-// C++ version will always be used.
-
-function swap(b, n, m) {
- const i = b[n];
- b[n] = b[m];
- b[m] = i;
-}
-
-Buffer.prototype.htons = function htons() {
- if (this.length % 2 !== 0)
- throw new RangeError();
- for (var i = 0; i < this.length; i += 2) {
- swap(this, i, i + 1);
- }
- return this;
-};
-
-Buffer.prototype.htonl = function htonl() {
- if (this.length % 4 !== 0)
- throw new RangeError();
- for (var i = 0; i < this.length; i += 4) {
- swap(this, i, i + 3);
- swap(this, i + 1, i + 2);
- }
- return this;
-};
-
-Buffer.prototype.htonll = function htonll() {
- if (this.length % 8 !== 0)
- throw new RangeError();
- for (var i = 0; i < this.length; i += 8) {
- swap(this, i, i + 7);
- swap(this, i + 1, i + 6);
- swap(this, i + 2, i + 5);
- swap(this, i + 3, i + 4);
- }
- return this;
-};
-
-function createBuffer(len, aligned) {
- len += aligned ? 0 : 1;
- const buf = Buffer.allocUnsafe(len);
- for (var i = 1; i <= len; i++)
- buf[i - 1] = i;
- return aligned ? buf : buf.slice(1);
-}
-
-function genMethod(method) {
- const fnString = `
- return function ${method}(n, buf) {
- for (var i = 0; i <= n; i++)
- buf.${method}();
- }`;
- return (new Function(fnString))();
-}
-
-function main({ method, len, n, aligned = 'true' }) {
- const buf = createBuffer(len, aligned === 'true');
- const bufferSwap = genMethod(method || 'swap16');
-
- bufferSwap(n, buf);
- bench.start();
- bufferSwap(n, buf);
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-tojson.js b/deps/node/benchmark/buffers/buffer-tojson.js
deleted file mode 100644
index 71936fb6..00000000
--- a/deps/node/benchmark/buffers/buffer-tojson.js
+++ /dev/null
@@ -1,17 +0,0 @@
-'use strict';
-
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- n: [1e4],
- len: [0, 10, 256, 4 * 1024]
-});
-
-function main({ n, len }) {
- const buf = Buffer.allocUnsafe(len);
-
- bench.start();
- for (var i = 0; i < n; ++i)
- buf.toJSON();
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-tostring.js b/deps/node/benchmark/buffers/buffer-tostring.js
deleted file mode 100644
index b2a14d8a..00000000
--- a/deps/node/benchmark/buffers/buffer-tostring.js
+++ /dev/null
@@ -1,45 +0,0 @@
-'use strict';
-
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- encoding: ['', 'utf8', 'ascii', 'latin1', 'binary', 'hex', 'UCS-2'],
- args: [0, 1, 2, 3],
- len: [0, 1, 64, 1024],
- n: [1e7]
-});
-
-function main({ encoding, args, len, n }) {
- const buf = Buffer.alloc(len, 42);
-
- if (encoding.length === 0)
- encoding = undefined;
-
- var i;
- switch (args) {
- case 1:
- bench.start();
- for (i = 0; i < n; i += 1)
- buf.toString(encoding);
- bench.end(n);
- break;
- case 2:
- bench.start();
- for (i = 0; i < n; i += 1)
- buf.toString(encoding, 0);
- bench.end(n);
- break;
- case 3:
- bench.start();
- for (i = 0; i < n; i += 1)
- buf.toString(encoding, 0, len);
- bench.end(n);
- break;
- default:
- bench.start();
- for (i = 0; i < n; i += 1)
- buf.toString();
- bench.end(n);
- break;
- }
-}
diff --git a/deps/node/benchmark/buffers/buffer-write-string.js b/deps/node/benchmark/buffers/buffer-write-string.js
deleted file mode 100644
index 6bd98ba4..00000000
--- a/deps/node/benchmark/buffers/buffer-write-string.js
+++ /dev/null
@@ -1,65 +0,0 @@
-'use strict';
-
-const common = require('../common.js');
-const bench = common.createBenchmark(main, {
- encoding: [
- '', 'utf8', 'ascii', 'hex', 'UCS-2', 'utf16le', 'latin1', 'binary',
- ],
- args: [ '', 'offset', 'offset+length' ],
- len: [10, 2048],
- n: [1e7]
-});
-
-function main({ len, n, encoding, args }) {
- const string = 'a'.repeat(len);
- const buf = Buffer.allocUnsafe(len);
-
- var i;
-
- switch (args) {
- case 'offset':
- if (encoding) {
- bench.start();
- for (i = 0; i < n; ++i) {
- buf.write(string, 0, encoding);
- }
- bench.end(n);
- } else {
- bench.start();
- for (i = 0; i < n; ++i) {
- buf.write(string, 0);
- }
- bench.end(n);
- }
- break;
- case 'offset+length':
- if (encoding) {
- bench.start();
- for (i = 0; i < n; ++i) {
- buf.write(string, 0, buf.length, encoding);
- }
- bench.end(n);
- } else {
- bench.start();
- for (i = 0; i < n; ++i) {
- buf.write(string, 0, buf.length);
- }
- bench.end(n);
- }
- break;
- default:
- if (encoding) {
- bench.start();
- for (i = 0; i < n; ++i) {
- buf.write(string, encoding);
- }
- bench.end(n);
- } else {
- bench.start();
- for (i = 0; i < n; ++i) {
- buf.write(string);
- }
- bench.end(n);
- }
- }
-}
diff --git a/deps/node/benchmark/buffers/buffer-write.js b/deps/node/benchmark/buffers/buffer-write.js
deleted file mode 100644
index 33d33a63..00000000
--- a/deps/node/benchmark/buffers/buffer-write.js
+++ /dev/null
@@ -1,101 +0,0 @@
-'use strict';
-const common = require('../common.js');
-
-const types = [
- 'UInt8',
- 'UInt16LE',
- 'UInt16BE',
- 'UInt32LE',
- 'UInt32BE',
- 'UIntLE',
- 'UIntBE',
- 'Int8',
- 'Int16LE',
- 'Int16BE',
- 'Int32LE',
- 'Int32BE',
- 'IntLE',
- 'IntBE',
- 'FloatLE',
- 'FloatBE',
- 'DoubleLE',
- 'DoubleBE',
-];
-
-const bench = common.createBenchmark(main, {
- buffer: ['fast', 'slow'],
- type: types,
- n: [1e6]
-});
-
-const INT8 = 0x7f;
-const INT16 = 0x7fff;
-const INT32 = 0x7fffffff;
-const INT48 = 0x7fffffffffff;
-const UINT8 = 0xff;
-const UINT16 = 0xffff;
-const UINT32 = 0xffffffff;
-
-const mod = {
- writeInt8: INT8,
- writeInt16BE: INT16,
- writeInt16LE: INT16,
- writeInt32BE: INT32,
- writeInt32LE: INT32,
- writeUInt8: UINT8,
- writeUInt16BE: UINT16,
- writeUInt16LE: UINT16,
- writeUInt32BE: UINT32,
- writeUInt32LE: UINT32,
- writeUIntLE: INT8,
- writeUIntBE: INT16,
- writeIntLE: INT32,
- writeIntBE: INT48
-};
-
-const byteLength = {
- writeUIntLE: 1,
- writeUIntBE: 2,
- writeIntLE: 4,
- writeIntBE: 6
-};
-
-function main({ n, buf, type }) {
- const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer;
- const buff = new clazz(8);
- const fn = `write${type || 'UInt8'}`;
-
- if (!/\d/.test(fn))
- benchSpecialInt(buff, fn, n);
- else if (/Int/.test(fn))
- benchInt(buff, fn, n);
- else
- benchFloat(buff, fn, n);
-}
-
-function benchInt(buff, fn, n) {
- const m = mod[fn];
- bench.start();
- for (var i = 0; i !== n; i++) {
- buff[fn](i & m, 0);
- }
- bench.end(n);
-}
-
-function benchSpecialInt(buff, fn, n) {
- const m = mod[fn];
- const byte = byteLength[fn];
- bench.start();
- for (var i = 0; i !== n; i++) {
- buff[fn](i & m, 0, byte);
- }
- bench.end(n);
-}
-
-function benchFloat(buff, fn, n) {
- bench.start();
- for (var i = 0; i !== n; i++) {
- buff[fn](i, 0);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/buffer-zero.js b/deps/node/benchmark/buffers/buffer-zero.js
deleted file mode 100644
index 1263732d..00000000
--- a/deps/node/benchmark/buffers/buffer-zero.js
+++ /dev/null
@@ -1,19 +0,0 @@
-'use strict';
-
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- n: [1024],
- type: ['buffer', 'string']
-});
-
-const zeroBuffer = Buffer.alloc(0);
-const zeroString = '';
-
-function main({ n, type }) {
- const data = type === 'buffer' ? zeroBuffer : zeroString;
-
- bench.start();
- for (var i = 0; i < n * 1024; i++) Buffer.from(data);
- bench.end(n);
-}
diff --git a/deps/node/benchmark/buffers/dataview-set.js b/deps/node/benchmark/buffers/dataview-set.js
deleted file mode 100644
index a22cad93..00000000
--- a/deps/node/benchmark/buffers/dataview-set.js
+++ /dev/null
@@ -1,72 +0,0 @@
-'use strict';
-const common = require('../common.js');
-
-const types = [
- 'Uint8',
- 'Uint16LE',
- 'Uint16BE',
- 'Uint32LE',
- 'Uint32BE',
- 'Int8',
- 'Int16LE',
- 'Int16BE',
- 'Int32LE',
- 'Int32BE',
- 'Float32LE',
- 'Float32BE',
- 'Float64LE',
- 'Float64BE',
-];
-
-const bench = common.createBenchmark(main, {
- type: types,
- n: [1e6]
-});
-
-const INT8 = 0x7f;
-const INT16 = 0x7fff;
-const INT32 = 0x7fffffff;
-const UINT8 = INT8 * 2;
-const UINT16 = INT16 * 2;
-const UINT32 = INT32 * 2;
-
-const mod = {
- setInt8: INT8,
- setInt16: INT16,
- setInt32: INT32,
- setUint8: UINT8,
- setUint16: UINT16,
- setUint32: UINT32
-};
-
-function main({ n, type }) {
- type = type || 'Uint8';
- const ab = new ArrayBuffer(8);
- const dv = new DataView(ab, 0, 8);
- const le = /LE$/.test(type);
- const fn = `set${type.replace(/[LB]E$/, '')}`;
-
- if (/int/i.test(fn))
- benchInt(dv, fn, n, le);
- else
- benchFloat(dv, fn, n, le);
-}
-
-function benchInt(dv, fn, len, le) {
- const m = mod[fn];
- const method = dv[fn];
- bench.start();
- for (var i = 0; i < len; i++) {
- method.call(dv, 0, i % m, le);
- }
- bench.end(len);
-}
-
-function benchFloat(dv, fn, len, le) {
- const method = dv[fn];
- bench.start();
- for (var i = 0; i < len; i++) {
- method.call(dv, 0, i * 0.1, le);
- }
- bench.end(len);
-}