Skip to content

Commit

Permalink
Revert "benchmark: remove special test entries"
Browse files Browse the repository at this point in the history
This reverts commit 357230f.

Refs: #31396
PR-URL: #31722
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
addaleax authored and targos committed Apr 28, 2020
1 parent 38de40a commit ef80c02
Show file tree
Hide file tree
Showing 41 changed files with 81 additions and 15 deletions.
4 changes: 3 additions & 1 deletion benchmark/assert/deepequal-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ 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: 2 additions & 0 deletions benchmark/assert/deepequal-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ 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: 4 additions & 1 deletion 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,6 +27,9 @@ 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: 2 additions & 0 deletions benchmark/assert/deepequal-prims-and-objs-big-array-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ 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: 3 additions & 1 deletion benchmark/assert/deepequal-prims-and-objs-big-loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ 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: 2 additions & 0 deletions benchmark/assert/deepequal-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ 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: 2 additions & 0 deletions benchmark/assert/deepequal-typedarrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ 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: 2 additions & 0 deletions benchmark/assert/throws.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ 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: 1 addition & 0 deletions benchmark/buffers/buffer-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ 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};
b.${type || 'fill(0)'};
}
`);
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];
const fn = methods[method || 'for'];

bench.start();
fn(buffer, n);
Expand Down
1 change: 1 addition & 0 deletions benchmark/buffers/buffer-read-float.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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}`;
const fn = `read${type || 'IntBE'}`;

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}`;
const fn = `read${type || 'UInt8'}`;

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);
const bufferSwap = genMethod(method || 'swap16');

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}`;
const fn = `write${type || 'UInt8'}`;

if (!/\d/.test(fn))
benchSpecialInt(buff, fn, n);
Expand Down
1 change: 1 addition & 0 deletions benchmark/buffers/dataview-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ 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: 3 additions & 0 deletions benchmark/crypto/aes-gcm-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ 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: 5 additions & 1 deletion benchmark/crypto/cipher-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ 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 @@ -24,6 +27,7 @@ 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: 2 additions & 0 deletions benchmark/es/defaultparams-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ 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: 2 additions & 0 deletions benchmark/es/destructuring-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ 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: 2 additions & 0 deletions benchmark/es/destructuring-object-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ 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: 2 additions & 0 deletions benchmark/es/foreach-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ 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: 2 additions & 0 deletions benchmark/es/map-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ 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: 2 additions & 0 deletions benchmark/es/restparams-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ 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: 2 additions & 0 deletions benchmark/es/spread-assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ 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: 2 additions & 0 deletions benchmark/es/spread-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ 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: 2 additions & 0 deletions benchmark/es/string-concatenations.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ 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: 2 additions & 0 deletions benchmark/es/string-repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ 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: 2 additions & 0 deletions benchmark/misc/arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ 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: 2 additions & 0 deletions benchmark/misc/getstringwidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ 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: 2 additions & 0 deletions benchmark/misc/object-property-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ 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: 2 additions & 0 deletions benchmark/misc/punycode.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ 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: 1 addition & 0 deletions benchmark/misc/trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function main({ n, method }) {
} = common.binding('trace_events');

switch (method) {
case '':
case 'trace':
doTrace(n, trace);
break;
Expand Down
4 changes: 4 additions & 0 deletions benchmark/misc/util-extend-vs-object-assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ 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: 2 additions & 1 deletion benchmark/util/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const bench = common.createBenchmark(main, {
});

function main({ n, type }) {
const [first, second] = inputs[type];
// For testing, if supplied with an empty type, default to string.
const [first, second] = inputs[type || 'string'];

bench.start();
for (let i = 0; i < n; i++) {
Expand Down
2 changes: 2 additions & 0 deletions benchmark/util/inspect-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ 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

0 comments on commit ef80c02

Please sign in to comment.