summaryrefslogtreecommitdiff
path: root/deps/node/benchmark/util
diff options
context:
space:
mode:
Diffstat (limited to 'deps/node/benchmark/util')
-rw-r--r--deps/node/benchmark/util/format.js32
-rw-r--r--deps/node/benchmark/util/inspect-array.js45
-rw-r--r--deps/node/benchmark/util/inspect-proxy.js15
-rw-r--r--deps/node/benchmark/util/inspect.js102
-rw-r--r--deps/node/benchmark/util/normalize-encoding.js59
-rw-r--r--deps/node/benchmark/util/priority-queue.js18
-rw-r--r--deps/node/benchmark/util/splice-one.js33
-rw-r--r--deps/node/benchmark/util/type-check.js52
8 files changed, 0 insertions, 356 deletions
diff --git a/deps/node/benchmark/util/format.js b/deps/node/benchmark/util/format.js
deleted file mode 100644
index 2a4a2009..00000000
--- a/deps/node/benchmark/util/format.js
+++ /dev/null
@@ -1,32 +0,0 @@
-'use strict';
-
-const util = require('util');
-const common = require('../common');
-
-const inputs = {
- 'string': ['Hello, my name is %s', 'Fred'],
- 'string-2': ['Hello, %s is my name', 'Fred'],
- 'number': ['Hi, I was born in %d', 1989],
- 'replace-object': ['An error occurred %j', { msg: 'This is an error' }],
- 'unknown': ['hello %a', 'test'],
- 'no-replace': [1, 2],
- 'no-replace-2': ['foobar', 'yeah', 'mensch', 5],
- 'only-objects': [{ msg: 'This is an error' }, { msg: 'This is an error' }],
- 'many-%': ['replace%%%%s%%%%many%s%s%s', 'percent'],
-};
-
-const bench = common.createBenchmark(main, {
- n: [1e5],
- type: Object.keys(inputs)
-});
-
-function main({ n, type }) {
- // For testing, if supplied with an empty type, default to string.
- const [first, second] = inputs[type || 'string'];
-
- bench.start();
- for (var i = 0; i < n; i++) {
- util.format(first, second);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/util/inspect-array.js b/deps/node/benchmark/util/inspect-array.js
deleted file mode 100644
index 4fd73785..00000000
--- a/deps/node/benchmark/util/inspect-array.js
+++ /dev/null
@@ -1,45 +0,0 @@
-'use strict';
-
-const common = require('../common');
-const util = require('util');
-
-const bench = common.createBenchmark(main, {
- n: [5e2],
- len: [1e2, 1e5],
- type: [
- 'denseArray',
- 'sparseArray',
- 'mixedArray',
- 'denseArray_showHidden',
- ]
-});
-
-function main({ n, len, type }) {
- var arr = Array(len);
- var i, opts;
-
- switch (type) {
- case 'denseArray_showHidden':
- opts = { showHidden: true };
- arr = arr.fill('denseArray');
- break;
- // For testing, if supplied with an empty type, default to denseArray.
- case '':
- case 'denseArray':
- arr = arr.fill('denseArray');
- break;
- case 'sparseArray':
- break;
- case 'mixedArray':
- for (i = 0; i < n; i += 2)
- arr[i] = i;
- break;
- default:
- throw new Error(`Unsupported type ${type}`);
- }
- bench.start();
- for (i = 0; i < n; i++) {
- util.inspect(arr, opts);
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/util/inspect-proxy.js b/deps/node/benchmark/util/inspect-proxy.js
deleted file mode 100644
index 3c82d50a..00000000
--- a/deps/node/benchmark/util/inspect-proxy.js
+++ /dev/null
@@ -1,15 +0,0 @@
-'use strict';
-
-const util = require('util');
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, { n: [2e4] });
-
-function main({ n }) {
- const proxyA = new Proxy({}, { get: () => {} });
- const proxyB = new Proxy(() => {}, {});
- bench.start();
- for (var i = 0; i < n; i += 1)
- util.inspect({ a: proxyA, b: proxyB }, { showProxy: true });
- bench.end(n);
-}
diff --git a/deps/node/benchmark/util/inspect.js b/deps/node/benchmark/util/inspect.js
deleted file mode 100644
index fd6f6158..00000000
--- a/deps/node/benchmark/util/inspect.js
+++ /dev/null
@@ -1,102 +0,0 @@
-'use strict';
-const util = require('util');
-
-const common = require('../common.js');
-
-const opts = {
- showHidden: { showHidden: true },
- colors: { colors: true },
- none: undefined
-};
-const bench = common.createBenchmark(main, {
- n: [2e4],
- method: [
- 'Object',
- 'Object_empty',
- 'Object_deep_ln',
- 'String',
- 'String_complex',
- 'String_boxed',
- 'Date',
- 'Set',
- 'Error',
- 'Array',
- 'TypedArray',
- 'TypedArray_extra',
- 'Number',
- ],
- option: Object.keys(opts)
-});
-
-function benchmark(n, obj, options) {
- bench.start();
- for (var i = 0; i < n; i += 1) {
- util.inspect(obj, options);
- }
- bench.end(n);
-}
-
-function main({ method, n, option }) {
- var obj;
- const options = opts[option];
- switch (method) {
- case 'Object':
- benchmark(n, { a: 'a', b: 'b', c: 'c', d: 'd' }, options);
- break;
- case 'Object_empty':
- benchmark(n, {}, options);
- break;
- case 'Object_deep_ln':
- if (options)
- options.depth = Infinity;
- obj = { first:
- { second:
- { third:
- { a: 'first',
- b: 'second',
- c: 'third',
- d: 'fourth',
- e: 'fifth',
- f: 'sixth',
- g: 'seventh' } } } };
- benchmark(n, obj, options || { depth: Infinity });
- break;
- case 'String':
- benchmark(n, 'Simple string', options);
- break;
- case 'String_complex':
- benchmark(n, 'This string\nhas to be\tescaped!', options);
- break;
- case 'String_boxed':
- benchmark(n, new String('string'), options);
- break;
- case 'Date':
- benchmark(n, new Date(), options);
- break;
- case 'Set':
- obj = new Set([5, 3]);
- benchmark(n, obj, options);
- break;
- case 'Error':
- benchmark(n, new Error('error'), options);
- break;
- case 'Array':
- benchmark(n, Array(50).fill().map((_, i) => i), options);
- break;
- case 'TypedArray':
- obj = new Uint8Array(Array(50).fill().map((_, i) => i));
- benchmark(n, obj, options);
- break;
- case 'TypedArray_extra':
- obj = new Uint8Array(Array(50).fill().map((_, i) => i));
- obj.foo = 'bar';
- obj[Symbol('baz')] = 5;
- benchmark(n, obj, options);
- break;
- case 'Number':
- benchmark(n, 0, options);
- break;
- default:
- throw new Error(`Unsupported method "${method}"`);
- }
-}
diff --git a/deps/node/benchmark/util/normalize-encoding.js b/deps/node/benchmark/util/normalize-encoding.js
deleted file mode 100644
index 464bda52..00000000
--- a/deps/node/benchmark/util/normalize-encoding.js
+++ /dev/null
@@ -1,59 +0,0 @@
-'use strict';
-
-const common = require('../common.js');
-const assert = require('assert');
-
-const groupedInputs = {
- group_common: ['undefined', 'utf8', 'utf-8', 'base64',
- 'binary', 'latin1', 'ucs2'],
- group_upper: ['UTF-8', 'UTF8', 'UCS2',
- 'UTF16LE', 'BASE64', 'UCS2'],
- group_uncommon: ['foo'],
- group_misc: ['', 'utf16le', 'hex', 'HEX', 'BINARY']
-};
-
-const inputs = [
- '', 'utf8', 'utf-8', 'UTF-8', 'UTF8', 'Utf8',
- 'ucs2', 'UCS2', 'utf16le', 'UTF16LE',
- 'binary', 'BINARY', 'latin1', 'base64', 'BASE64',
- 'hex', 'HEX', 'foo', 'undefined',
-];
-
-const bench = common.createBenchmark(main, {
- input: inputs.concat(Object.keys(groupedInputs)),
- n: [1e5]
-}, {
- flags: '--expose-internals'
-});
-
-function getInput(input) {
- switch (input) {
- case 'group_common':
- return groupedInputs.group_common;
- case 'group_upper':
- return groupedInputs.group_upper;
- case 'group_uncommon':
- return groupedInputs.group_uncommon;
- case 'group_misc':
- return groupedInputs.group_misc;
- case 'undefined':
- return [undefined];
- default:
- return [input];
- }
-}
-
-function main({ input, n }) {
- const { normalizeEncoding } = require('internal/util');
- const inputs = getInput(input);
- var noDead = '';
-
- bench.start();
- for (var i = 0; i < n; ++i) {
- for (var j = 0; j < inputs.length; ++j) {
- noDead = normalizeEncoding(inputs[j]);
- }
- }
- bench.end(n);
- assert.ok(noDead === undefined || noDead.length > 0);
-}
diff --git a/deps/node/benchmark/util/priority-queue.js b/deps/node/benchmark/util/priority-queue.js
deleted file mode 100644
index 9cff7cbb..00000000
--- a/deps/node/benchmark/util/priority-queue.js
+++ /dev/null
@@ -1,18 +0,0 @@
-'use strict';
-
-const common = require('../common');
-
-const bench = common.createBenchmark(main, {
- n: [1e5]
-}, { flags: ['--expose-internals'] });
-
-function main({ n, type }) {
- const PriorityQueue = require('internal/priority_queue');
- const queue = new PriorityQueue();
- bench.start();
- for (var i = 0; i < n; i++)
- queue.insert(Math.random() * 1e7 | 0);
- for (i = 0; i < n; i++)
- queue.shift();
- bench.end(n);
-}
diff --git a/deps/node/benchmark/util/splice-one.js b/deps/node/benchmark/util/splice-one.js
deleted file mode 100644
index 4ca7c856..00000000
--- a/deps/node/benchmark/util/splice-one.js
+++ /dev/null
@@ -1,33 +0,0 @@
-'use strict';
-
-const common = require('../common');
-
-const bench = common.createBenchmark(main, {
- n: [1e5],
- pos: ['start', 'middle', 'end'],
- size: [10, 100, 500],
-}, { flags: ['--expose-internals'] });
-
-function main({ n, pos, size }) {
- const { spliceOne } = require('internal/util');
- const arr = new Array(size);
- arr.fill('');
- let index;
- switch (pos) {
- case 'end':
- index = size - 1;
- break;
- case 'middle':
- index = Math.floor(size / 2);
- break;
- default: // start
- index = 0;
- }
-
- bench.start();
- for (var i = 0; i < n; i++) {
- spliceOne(arr, index);
- arr.push('');
- }
- bench.end(n);
-}
diff --git a/deps/node/benchmark/util/type-check.js b/deps/node/benchmark/util/type-check.js
deleted file mode 100644
index f1147198..00000000
--- a/deps/node/benchmark/util/type-check.js
+++ /dev/null
@@ -1,52 +0,0 @@
-'use strict';
-
-const common = require('../common');
-
-const arrayBuffer = new ArrayBuffer();
-const dataView = new DataView(arrayBuffer);
-const uint8Array = new Uint8Array(arrayBuffer);
-const int32Array = new Int32Array(arrayBuffer);
-
-const args = {
- ArrayBufferView: {
- 'true': dataView,
- 'false-primitive': true,
- 'false-object': arrayBuffer
- },
- TypedArray: {
- 'true': int32Array,
- 'false-primitive': true,
- 'false-object': arrayBuffer
- },
- Uint8Array: {
- 'true': uint8Array,
- 'false-primitive': true,
- 'false-object': int32Array
- }
-};
-
-const bench = common.createBenchmark(main, {
- type: Object.keys(args),
- version: ['native', 'js'],
- argument: ['true', 'false-primitive', 'false-object'],
- n: [1e5]
-}, {
- flags: ['--expose-internals']
-});
-
-function main({ type, argument, version, n }) {
- // For testing, if supplied with an empty type, default to ArrayBufferView.
- type = type || 'ArrayBufferView';
-
- const util = common.binding('util');
- const types = require('internal/util/types');
-
- const func = { native: util, js: types }[version][`is${type}`];
- const arg = args[type][argument];
-
- bench.start();
- for (var i = 0; i < n; i++) {
- func(arg);
- }
- bench.end(n);
-}