Skip to content

Commit

Permalink
benchmark: remove special test entries
Browse files Browse the repository at this point in the history
It was necessary to have fallbacks to run the original tests. This
is obsolete with the new test mode.

PR-URL: #31396
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
BridgeAR authored and codebytere committed Mar 30, 2020
1 parent 19fbe55 commit c18cec7
Show file tree
Hide file tree
Showing 41 changed files with 15 additions and 81 deletions.
4 changes: 1 addition & 3 deletions benchmark/assert/deepequal-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions benchmark/assert/deepequal-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions benchmark/assert/deepequal-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '') {
Expand All @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions benchmark/assert/deepequal-prims-and-objs-big-array-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions benchmark/assert/deepequal-prims-and-objs-big-loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions benchmark/assert/deepequal-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions benchmark/assert/deepequal-typedarrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions benchmark/assert/throws.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions benchmark/buffers/buffer-bytelength.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion benchmark/buffers/buffer-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/buffers/buffer-fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion benchmark/buffers/buffer-iterate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion benchmark/buffers/buffer-read-float.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/buffers/buffer-read-with-byteLength.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion benchmark/buffers/buffer-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion benchmark/buffers/buffer-swap.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,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();
Expand Down
2 changes: 1 addition & 1 deletion benchmark/buffers/buffer-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion benchmark/buffers/dataview-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions benchmark/crypto/aes-gcm-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions benchmark/crypto/cipher-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ 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']
});

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.
Expand All @@ -27,7 +24,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');
Expand Down
2 changes: 0 additions & 2 deletions benchmark/es/defaultparams-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions benchmark/es/destructuring-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions benchmark/es/destructuring-object-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions benchmark/es/foreach-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions benchmark/es/map-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions benchmark/es/restparams-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions benchmark/es/spread-assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
2 changes: 0 additions & 2 deletions benchmark/es/spread-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
2 changes: 0 additions & 2 deletions benchmark/es/string-concatenations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
2 changes: 0 additions & 2 deletions benchmark/es/string-repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
2 changes: 0 additions & 2 deletions benchmark/misc/arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions benchmark/misc/getstringwidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ({
Expand Down
2 changes: 0 additions & 2 deletions benchmark/misc/object-property-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions benchmark/misc/punycode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion benchmark/misc/trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ function main({ n, method }) {
} = common.binding('trace_events');

switch (method) {
case '':
case 'trace':
doTrace(n, trace);
break;
Expand Down
4 changes: 0 additions & 4 deletions benchmark/misc/util-extend-vs-object-assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/url/url-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion benchmark/url/url-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions benchmark/util/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/util/inspect-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit c18cec7

Please sign in to comment.