benchmark: remove special test entries

It was necessary to have fallbacks to run the original tests. This
is obsolete with the new test mode.

PR-URL: https://github.com/nodejs/node/pull/31396
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Ruben Bridgewater 2020-01-20 09:21:56 +01:00
parent 78aa348f4e
commit 357230f4b7
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
41 changed files with 15 additions and 81 deletions

View File

@ -10,8 +10,6 @@ const bench = common.createBenchmark(main, {
}); });
function main({ len, n, method, strict }) { function main({ len, n, method, strict }) {
if (!method)
method = 'deepEqual';
const data = Buffer.allocUnsafe(len + 1); const data = Buffer.allocUnsafe(len + 1);
const actual = Buffer.alloc(len); const actual = Buffer.alloc(len);
const expected = Buffer.alloc(len); const expected = Buffer.alloc(len);

View File

@ -34,8 +34,6 @@ function main({ n, len, method, strict }) {
const array = Array(len).fill(1); const array = Array(len).fill(1);
switch (method) { switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'deepEqual_primitiveOnly': { case 'deepEqual_primitiveOnly': {
const values = array.map((_, i) => [`str_${i}`, 123]); const values = array.map((_, i) => [`str_${i}`, 123]);
benchmark(strict ? deepStrictEqual : deepEqual, n, values); benchmark(strict ? deepStrictEqual : deepEqual, n, values);

View File

@ -27,9 +27,6 @@ function main({ size, n, method, strict }) {
// TODO: Fix this "hack". `n` should not be manipulated. // TODO: Fix this "hack". `n` should not be manipulated.
n = Math.min(Math.ceil(n / size), 20); n = Math.min(Math.ceil(n / size), 20);
if (!method)
method = 'deepEqual';
const source = Array.apply(null, Array(size)); const source = Array.apply(null, Array(size));
const actual = createObj(source); const actual = createObj(source);
const expected = createObj(source); const expected = createObj(source);

View File

@ -52,8 +52,6 @@ function main({ n, len, primitive, method, strict }) {
const expectedWrongSet = new Set(expectedWrong); const expectedWrongSet = new Set(expectedWrong);
switch (method) { switch (method) {
// Empty string falls through to next line as default, mostly for tests.
case '':
case 'deepEqual_Array': case 'deepEqual_Array':
run(strict ? deepStrictEqual : deepEqual, n, actual, expected); run(strict ? deepStrictEqual : deepEqual, n, actual, expected);
break; break;

View File

@ -17,8 +17,6 @@ const bench = common.createBenchmark(main, {
}); });
function main({ n, primitive, method, strict }) { function main({ n, primitive, method, strict }) {
if (!method)
method = 'deepEqual';
const prim = primValues[primitive]; const prim = primValues[primitive];
const actual = prim; const actual = prim;
const expected = prim; const expected = prim;

View File

@ -34,8 +34,6 @@ function main({ n, len, method, strict }) {
const array = Array(len).fill(1); const array = Array(len).fill(1);
switch (method) { switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'deepEqual_primitiveOnly': { case 'deepEqual_primitiveOnly': {
const values = array.map((_, i) => `str_${i}`); const values = array.map((_, i) => `str_${i}`);
benchmark(strict ? deepStrictEqual : deepEqual, n, values); benchmark(strict ? deepStrictEqual : deepEqual, n, values);

View File

@ -20,8 +20,6 @@ const bench = common.createBenchmark(main, {
}); });
function main({ type, n, len, method, strict }) { function main({ type, n, len, method, strict }) {
if (!method)
method = 'deepEqual';
const clazz = global[type]; const clazz = global[type];
const actual = new clazz(len); const actual = new clazz(len);
const expected = new clazz(len); const expected = new clazz(len);

View File

@ -15,8 +15,6 @@ function main({ n, method }) {
const message = 'failure'; const message = 'failure';
switch (method) { switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'doesNotThrow': case 'doesNotThrow':
bench.start(); bench.start();
for (let i = 0; i < n; ++i) { for (let i = 0; i < n; ++i) {

View File

@ -16,7 +16,6 @@ const bench = common.createBenchmark(main, {
function main({ len, n, type }) { function main({ len, n, type }) {
let fn, i; let fn, i;
switch (type) { switch (type) {
case '':
case 'fast-alloc': case 'fast-alloc':
fn = Buffer.alloc; fn = Buffer.alloc;
break; break;

View File

@ -22,7 +22,7 @@ function main({ n, type, size }) {
const buffer = Buffer.allocUnsafe(size); const buffer = Buffer.allocUnsafe(size);
const testFunction = new Function('b', ` const testFunction = new Function('b', `
for (var i = 0; i < ${n}; i++) { for (var i = 0; i < ${n}; i++) {
b.${type || 'fill(0)'}; b.${type};
} }
`); `);
bench.start(); bench.start();

View File

@ -21,7 +21,7 @@ function main({ size, type, method, n }) {
Buffer.alloc(size) : Buffer.alloc(size) :
SlowBuffer(size).fill(0); SlowBuffer(size).fill(0);
const fn = methods[method || 'for']; const fn = methods[method];
bench.start(); bench.start();
fn(buffer, n); fn(buffer, n);

View File

@ -9,7 +9,6 @@ const bench = common.createBenchmark(main, {
}); });
function main({ n, type, endian, value }) { function main({ n, type, endian, value }) {
type = type || 'Double';
const buff = Buffer.alloc(8); const buff = Buffer.alloc(8);
const fn = `read${type}${endian}`; const fn = `read${type}${endian}`;
const values = { const values = {

View File

@ -19,7 +19,7 @@ function main({ n, buf, type, byteLength }) {
const buff = buf === 'fast' ? const buff = buf === 'fast' ?
Buffer.alloc(8) : Buffer.alloc(8) :
require('buffer').SlowBuffer(8); require('buffer').SlowBuffer(8);
const fn = `read${type || 'IntBE'}`; const fn = `read${type}`;
buff.writeDoubleLE(0, 0); buff.writeDoubleLE(0, 0);
bench.start(); bench.start();

View File

@ -28,7 +28,7 @@ function main({ n, buf, type }) {
const buff = buf === 'fast' ? const buff = buf === 'fast' ?
Buffer.alloc(8) : Buffer.alloc(8) :
require('buffer').SlowBuffer(8); require('buffer').SlowBuffer(8);
const fn = `read${type || 'UInt8'}`; const fn = `read${type}`;
buff.writeDoubleLE(0, 0); buff.writeDoubleLE(0, 0);
bench.start(); bench.start();

View File

@ -76,7 +76,7 @@ function genMethod(method) {
function main({ method, len, n, aligned = 'true' }) { function main({ method, len, n, aligned = 'true' }) {
const buf = createBuffer(len, aligned === 'true'); const buf = createBuffer(len, aligned === 'true');
const bufferSwap = genMethod(method || 'swap16'); const bufferSwap = genMethod(method);
bufferSwap(n, buf); bufferSwap(n, buf);
bench.start(); bench.start();

View File

@ -74,7 +74,7 @@ function main({ n, buf, type }) {
const buff = buf === 'fast' ? const buff = buf === 'fast' ?
Buffer.alloc(8) : Buffer.alloc(8) :
require('buffer').SlowBuffer(8); require('buffer').SlowBuffer(8);
const fn = `write${type || 'UInt8'}`; const fn = `write${type}`;
if (!/\d/.test(fn)) if (!/\d/.test(fn))
benchSpecialInt(buff, fn, n); benchSpecialInt(buff, fn, n);

View File

@ -40,7 +40,6 @@ const mod = {
}; };
function main({ n, type }) { function main({ n, type }) {
type = type || 'Uint8';
const ab = new ArrayBuffer(8); const ab = new ArrayBuffer(8);
const dv = new DataView(ab, 0, 8); const dv = new DataView(ab, 0, 8);
const le = /LE$/.test(type); const le = /LE$/.test(type);

View File

@ -9,9 +9,6 @@ const bench = common.createBenchmark(main, {
}); });
function main({ n, len, cipher }) { function main({ n, len, cipher }) {
// Default cipher for tests.
if (cipher === '')
cipher = 'aes-128-gcm';
const message = Buffer.alloc(len, 'b'); const message = Buffer.alloc(len, 'b');
const key = crypto.randomBytes(keylen[cipher]); const key = crypto.randomBytes(keylen[cipher]);
const iv = crypto.randomBytes(12); const iv = crypto.randomBytes(12);

View File

@ -12,9 +12,6 @@ const bench = common.createBenchmark(main, {
}); });
function main({ api, cipher, type, len, writes }) { function main({ api, cipher, type, len, writes }) {
// Default cipher for tests.
if (cipher === '')
cipher = 'AES192';
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) { if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
console.error('Crypto streams not available until v0.10'); console.error('Crypto streams not available until v0.10');
// Use the legacy, just so that we can compare them. // Use the legacy, just so that we can compare them.
@ -29,7 +26,6 @@ function main({ api, cipher, type, len, writes }) {
alice.generateKeys(); alice.generateKeys();
bob.generateKeys(); bob.generateKeys();
const pubEnc = /^v0\.[0-8]/.test(process.version) ? 'binary' : null; const pubEnc = /^v0\.[0-8]/.test(process.version) ? 'binary' : null;
const alice_secret = alice.computeSecret(bob.getPublicKey(), pubEnc, 'hex'); const alice_secret = alice.computeSecret(bob.getPublicKey(), pubEnc, 'hex');
const bob_secret = bob.computeSecret(alice.getPublicKey(), pubEnc, 'hex'); const bob_secret = bob.computeSecret(alice.getPublicKey(), pubEnc, 'hex');

View File

@ -36,8 +36,6 @@ function runDefaultParams(n) {
function main({ n, method }) { function main({ n, method }) {
switch (method) { switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'withoutdefaults': case 'withoutdefaults':
runOldStyleDefaults(n); runOldStyleDefaults(n);
break; break;

View File

@ -36,8 +36,6 @@ function runSwapDestructured(n) {
function main({ n, method }) { function main({ n, method }) {
switch (method) { switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'swap': case 'swap':
runSwapManual(n); runSwapManual(n);
break; break;

View File

@ -33,8 +33,6 @@ function runDestructured(n) {
function main({ n, method }) { function main({ n, method }) {
switch (method) { switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'normal': case 'normal':
runNormal(n); runNormal(n);
break; break;

View File

@ -54,8 +54,6 @@ function main({ n, count, method }) {
items[i] = i; items[i] = i;
switch (method) { switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'for': case 'for':
fn = useFor; fn = useFor;
break; break;

View File

@ -104,8 +104,6 @@ function runMap(n) {
function main({ n, method }) { function main({ n, method }) {
switch (method) { switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'object': case 'object':
runObject(n); runObject(n);
break; break;

View File

@ -51,8 +51,6 @@ function runUseArguments(n) {
function main({ n, method }) { function main({ n, method }) {
let fn; let fn;
switch (method) { switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'copy': case 'copy':
fn = runCopyArguments; fn = runCopyArguments;
break; break;

View File

@ -18,8 +18,6 @@ function main({ n, context, count, rest, method }) {
let obj; // eslint-disable-line no-unused-vars let obj; // eslint-disable-line no-unused-vars
switch (method) { switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case '_extend': case '_extend':
bench.start(); bench.start();
for (let i = 0; i < n; i++) for (let i = 0; i < n; i++)

View File

@ -32,8 +32,6 @@ function main({ n, context, count, rest, method }) {
args[i] = i; args[i] = i;
switch (method) { switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'apply': case 'apply':
bench.start(); bench.start();
for (let i = 0; i < n; i++) for (let i = 0; i < n; i++)

View File

@ -23,8 +23,6 @@ function main({ n, mode }) {
let string; let string;
switch (mode) { switch (mode) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'multi-concat': case 'multi-concat':
bench.start(); bench.start();
for (let i = 0; i < n; i++) for (let i = 0; i < n; i++)

View File

@ -18,8 +18,6 @@ function main({ n, size, encoding, mode }) {
let str; let str;
switch (mode) { switch (mode) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'Array': case 'Array':
bench.start(); bench.start();
for (let i = 0; i < n; i++) for (let i = 0; i < n; i++)

View File

@ -34,8 +34,6 @@ function usingPredefined() {
function main({ n, method, args }) { function main({ n, method, args }) {
let fn; let fn;
switch (method) { switch (method) {
// '' is a default case for tests
case '':
case 'restAndSpread': case 'restAndSpread':
fn = usingRestAndSpread; fn = usingRestAndSpread;
break; break;

View File

@ -10,8 +10,6 @@ const bench = common.createBenchmark(main, {
}); });
function main({ n, type }) { function main({ n, type }) {
// Default value for testing purposes.
type = type || 'ascii';
const { getStringWidth } = require('internal/util/inspect'); const { getStringWidth } = require('internal/util/inspect');
const str = ({ const str = ({

View File

@ -64,8 +64,6 @@ function runSymbol(n) {
function main({ n, method }) { function main({ n, method }) {
switch (method) { switch (method) {
// '' is a default case for tests
case '':
case 'property': case 'property':
runProperty(n); runProperty(n);
break; break;

View File

@ -62,8 +62,6 @@ function runICU(n, val) {
function main({ n, val, method }) { function main({ n, val, method }) {
switch (method) { switch (method) {
// '' is a default case for tests
case '':
case 'punycode': case 'punycode':
runPunycode(n, val); runPunycode(n, val);
break; break;

View File

@ -41,7 +41,6 @@ function main({ n, method }) {
} = common.binding('trace_events'); } = common.binding('trace_events');
switch (method) { switch (method) {
case '':
case 'trace': case 'trace':
doTrace(n, trace); doTrace(n, trace);
break; break;

View File

@ -9,10 +9,6 @@ const bench = common.createBenchmark(main, {
}); });
function main({ n, type }) { function main({ n, type }) {
// Default value for tests.
if (type === '')
type = 'extend';
let fn; let fn;
if (type === 'extend') { if (type === 'extend') {
fn = util._extend; fn = util._extend;

View File

@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {
}); });
function main({ type, n }) { function main({ type, n }) {
const input = inputs[type] || ''; const input = inputs[type];
// Force-optimize url.format() so that the benchmark doesn't get // Force-optimize url.format() so that the benchmark doesn't get
// disrupted by the optimizer kicking in halfway through. // disrupted by the optimizer kicking in halfway through.

View File

@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {
}); });
function main({ type, n }) { function main({ type, n }) {
const input = inputs[type] || ''; const input = inputs[type];
bench.start(); bench.start();
for (let i = 0; i < n; i += 1) for (let i = 0; i < n; i += 1)

View File

@ -23,8 +23,7 @@ const bench = common.createBenchmark(main, {
}); });
function main({ n, type }) { function main({ n, type }) {
// For testing, if supplied with an empty type, default to string. const [first, second] = inputs[type];
const [first, second] = inputs[type || 'string'];
bench.start(); bench.start();
for (let i = 0; i < n; i++) { for (let i = 0; i < n; i++) {

View File

@ -23,8 +23,6 @@ function main({ n, len, type }) {
opts = { showHidden: true }; opts = { showHidden: true };
arr = arr.fill('denseArray'); arr = arr.fill('denseArray');
break; break;
// For testing, if supplied with an empty type, default to denseArray.
case '':
case 'denseArray': case 'denseArray':
arr = arr.fill('denseArray'); arr = arr.fill('denseArray');
break; break;

View File

@ -35,9 +35,6 @@ const bench = common.createBenchmark(main, {
}); });
function main({ type, argument, version, n }) { 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 util = common.binding('util');
const types = require('internal/util/types'); const types = require('internal/util/types');