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

@ -6,12 +6,10 @@ const bench = common.createBenchmark(main, {
n: [2e4],
len: [1e2, 1e3],
strict: [0, 1],
method: [ 'deepEqual', 'notDeepEqual' ],
method: ['deepEqual', 'notDeepEqual'],
});
function main({ len, n, method, strict }) {
if (!method)
method = 'deepEqual';
const data = Buffer.allocUnsafe(len + 1);
const actual = 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);
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'deepEqual_primitiveOnly': {
const values = array.map((_, i) => [`str_${i}`, 123]);
benchmark(strict ? deepStrictEqual : deepEqual, n, values);

View File

@ -7,7 +7,7 @@ const bench = common.createBenchmark(main, {
n: [5e3],
size: [1e2, 1e3, 5e4],
strict: [0, 1],
method: [ 'deepEqual', 'notDeepEqual' ],
method: ['deepEqual', 'notDeepEqual'],
});
function createObj(source, add = '') {
@ -27,9 +27,6 @@ function main({ size, n, method, strict }) {
// TODO: Fix this "hack". `n` should not be manipulated.
n = Math.min(Math.ceil(n / size), 20);
if (!method)
method = 'deepEqual';
const source = Array.apply(null, Array(size));
const actual = createObj(source);
const expected = createObj(source);

View File

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

View File

@ -13,12 +13,10 @@ const bench = common.createBenchmark(main, {
primitive: Object.keys(primValues),
n: [2e4],
strict: [0, 1],
method: [ 'deepEqual', 'notDeepEqual' ],
method: ['deepEqual', 'notDeepEqual'],
});
function main({ n, primitive, method, strict }) {
if (!method)
method = 'deepEqual';
const prim = primValues[primitive];
const actual = prim;
const expected = prim;

View File

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

View File

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

View File

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

View File

@ -17,9 +17,9 @@ const chars = [
function main({ n, len, encoding }) {
let strings = [];
let results = [ len * 16 ];
let results = [len * 16];
if (encoding === 'buffer') {
strings = [ Buffer.alloc(len * 16, 'a') ];
strings = [Buffer.alloc(len * 16, 'a')];
} else {
for (const string of chars) {
// Strings must be built differently, depending on encoding

View File

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

View File

@ -22,7 +22,7 @@ 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)'};
b.${type};
}
`);
bench.start();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, {
writes: [500],
cipher: [ 'AES192', 'AES256' ],
cipher: ['AES192', 'AES256'],
type: ['asc', 'utf', 'buf'],
len: [2, 1024, 102400, 1024 * 1024],
api: ['legacy', 'stream']
@ -12,9 +12,6 @@ const bench = common.createBenchmark(main, {
});
function main({ api, cipher, type, len, writes }) {
// Default cipher for tests.
if (cipher === '')
cipher = 'AES192';
if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
console.error('Crypto streams not available until v0.10');
// Use the legacy, just so that we can compare them.
@ -29,7 +26,6 @@ function main({ api, cipher, type, len, writes }) {
alice.generateKeys();
bob.generateKeys();
const pubEnc = /^v0\.[0-8]/.test(process.version) ? 'binary' : null;
const alice_secret = alice.computeSecret(bob.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 }) {
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'withoutdefaults':
runOldStyleDefaults(n);
break;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,8 +23,6 @@ function main({ n, len, type }) {
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;

View File

@ -35,9 +35,6 @@ const bench = common.createBenchmark(main, {
});
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');