Skip to content

Commit

Permalink
benchmark: add trailing commas
Browse files Browse the repository at this point in the history
PR-URL: #46370
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
aduh95 authored and juanarbol committed Mar 3, 2023
1 parent 8b75237 commit e028a28
Show file tree
Hide file tree
Showing 83 changed files with 133 additions and 115 deletions.
32 changes: 25 additions & 7 deletions benchmark/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,29 @@ env:
es6: true

rules:
comma-dangle: [error, {
arrays: always-multiline,
exports: always-multiline,
functions: only-multiline,
imports: always-multiline,
objects: only-multiline,
}]
prefer-arrow-callback: error

overrides:
- files:
- async_hooks/*.js
- buffers/*.js
- buffers-fill/*.js
- crypto/*.js
- fs/*.js
- http/*.js
- http2/*.js
- misc/*.js
- module/*.js
- net/*.js
- path/*.js
- process/*.js
- url/*.js
- util/*.js
rules:
comma-dangle: [error, {
arrays: always-multiline,
exports: always-multiline,
functions: only-multiline,
imports: always-multiline,
objects: only-multiline,
}]
4 changes: 2 additions & 2 deletions benchmark/_http-benchmarkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class TestDoubleBenchmarker {
const scheme = options.scheme || 'http';
const env = {
test_url: `${scheme}://127.0.0.1:${options.port}${options.path}`,
...process.env
...process.env,
};

const child = child_process.fork(this.executable,
Expand Down Expand Up @@ -203,7 +203,7 @@ exports.run = function(options, callback) {
connections: 100,
duration: 5,
benchmarker: exports.default_http_benchmarker,
...options
...options,
};
if (!options.benchmarker) {
callback(new Error('Could not locate required http benchmarker. See ' +
Expand Down
4 changes: 2 additions & 2 deletions benchmark/assert/deepequal-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function main({ n, len, method, strict }) {
}
case 'deepEqual_mixed': {
const values = array.map(
(_, i) => [i % 2 ? [`str_${i}`, 1] : `str_${i}`, 123]
(_, i) => [i % 2 ? [`str_${i}`, 1] : `str_${i}`, 123],
);
benchmark(strict ? deepStrictEqual : deepEqual, n, values);
break;
Expand All @@ -67,7 +67,7 @@ function main({ n, len, method, strict }) {
}
case 'notDeepEqual_mixed': {
const values = array.map(
(_, i) => [i % 2 ? [`str_${i}`, 1] : `str_${i}`, 123]
(_, i) => [i % 2 ? [`str_${i}`, 1] : `str_${i}`, 123],
);
const values2 = values.slice(0);
values2[0] = ['w00t', 123];
Expand Down
2 changes: 1 addition & 1 deletion benchmark/blob/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { Blob } = require('buffer');
const bench = common.createBenchmark(main, {
bytes: [128, 1024, 1024 ** 2],
n: [1e6],
operation: ['text', 'arrayBuffer']
operation: ['text', 'arrayBuffer'],
});

async function run(n, bytes, operation) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/blob/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { File } = require('buffer');
const bench = common.createBenchmark(main, {
bytes: [128, 1024, 1024 ** 2],
n: [1e6],
operation: ['text', 'arrayBuffer']
operation: ['text', 'arrayBuffer'],
});

const options = {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/child_process/child-process-exec-stdout.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (!isWindows) messagesLength.push(32768);

const bench = common.createBenchmark(childProcessExecStdout, {
len: messagesLength,
dur: [5]
dur: [5],
});

function childProcessExecStdout({ dur, len }) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/child_process/child-process-read-ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (process.argv[2] === 'child') {
64, 256, 1024, 4096, 16384, 65536,
65536 << 4, 65536 << 6 - 1,
],
dur: [5]
dur: [5],
});
const spawn = require('child_process').spawn;

Expand Down
2 changes: 1 addition & 1 deletion benchmark/child_process/child-process-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (os.platform() !== 'win32')

const bench = common.createBenchmark(main, {
len: messagesLength,
dur: [5]
dur: [5],
});

function main({ dur, len }) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/child_process/spawn-echo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [1000]
n: [1000],
});

const spawn = require('child_process').spawn;
Expand Down
4 changes: 2 additions & 2 deletions benchmark/cluster/echo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ if (cluster.isMaster) {
payload: ['string', 'object'],
sendsPerBroadcast: [1, 10],
serialization: ['json', 'advanced'],
n: [1e5]
n: [1e5],
});

function main({
n,
workers,
sendsPerBroadcast,
payload,
serialization
serialization,
}) {
const expectedPerBroadcast = sendsPerBroadcast * workers;
let readies = 0;
Expand Down
6 changes: 3 additions & 3 deletions benchmark/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Benchmark {
cliOptions[key] = [];
cliOptions[key].push(
// Infer the type from the config object and parse accordingly
typeof configs[key][0] === 'number' ? +value : value
typeof configs[key][0] === 'number' ? +value : value,
);
} else {
extraOptions[key] = value;
Expand Down Expand Up @@ -148,7 +148,7 @@ class Benchmark {
const allowed = combinationFilter({ ...currConfig });
if (typeof allowed !== 'boolean') {
throw new TypeError(
'Combination filter must always return a boolean'
'Combination filter must always return a boolean',
);
}
if (allowed)
Expand Down Expand Up @@ -183,7 +183,7 @@ class Benchmark {
}
this.config.benchmarker = used_benchmarker;
this.report(result, elapsed);
}
},
);
}

Expand Down
2 changes: 1 addition & 1 deletion benchmark/compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ if (showProgress) {
const job = queue[i];

const child = fork(path.resolve(__dirname, job.filename), cli.optional.set, {
execPath: cli.optional[job.binary]
execPath: cli.optional[job.binary],
});

child.on('message', (data) => {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/dgram/array-vs-concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {
num: [100],
chunks: [1, 2, 4, 8],
type: ['concat', 'multi'],
dur: [5]
dur: [5],
});

function main({ dur, len, num, type, chunks }) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/dgram/multi-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {
num: [100],
chunks: [1, 2, 4, 8],
type: ['send', 'recv'],
dur: [5]
dur: [5],
});

function main({ dur, len, num, type, chunks }) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/dgram/offset-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const bench = common.createBenchmark(main, {
len: [1, 64, 256, 1024],
num: [100],
type: ['send', 'recv'],
dur: [5]
dur: [5],
});

function main({ dur, len, num, type }) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/dgram/single-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const bench = common.createBenchmark(main, {
len: [1, 64, 256, 1024],
num: [100],
type: ['send', 'recv'],
dur: [5]
dur: [5],
});

function main({ dur, len, num, type }) {
Expand Down
12 changes: 6 additions & 6 deletions benchmark/diagnostics_channel/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const bench = common.createBenchmark(main, {
chunks: 4,
connections: [50, 500],
chunkedEnc: 1,
duration: 5
duration: 5,
});

function main({ apm, connections, duration, type, len, chunks, chunkedEnc }) {
Expand All @@ -24,7 +24,7 @@ function main({ apm, connections, duration, type, len, chunks, chunkedEnc }) {
bench.http({
path,
connections,
duration
duration,
}, () => {
server.close();
if (done) done();
Expand All @@ -44,14 +44,14 @@ function patch() {
if (name === 'request') {
als.enterWith({
url: req.url,
start: process.hrtime.bigint()
start: process.hrtime.bigint(),
});

res.on('finish', () => {
times.push({
...als.getStore(),
statusCode: res.statusCode,
end: process.hrtime.bigint()
end: process.hrtime.bigint(),
});
});
}
Expand All @@ -74,15 +74,15 @@ function diagnostics_channel() {
function onStart(req) {
als.enterWith({
url: req.url,
start: process.hrtime.bigint()
start: process.hrtime.bigint(),
});
}

function onFinish(res) {
times.push({
...als.getStore(),
statusCode: res.statusCode,
end: process.hrtime.bigint()
end: process.hrtime.bigint(),
});
}

Expand Down
2 changes: 1 addition & 1 deletion benchmark/diagnostics_channel/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function main({ n, subscribers }) {
}

const data = {
foo: 'bar'
foo: 'bar',
};

bench.start();
Expand Down
2 changes: 1 addition & 1 deletion benchmark/dns/lookup-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { lookup } = require('dns').promises;
const bench = common.createBenchmark(main, {
name: ['127.0.0.1', '::1'],
all: ['true', 'false'],
n: [5e6]
n: [5e6],
});

function main({ name, n, all }) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/dns/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const lookup = require('dns').lookup;
const bench = common.createBenchmark(main, {
name: ['127.0.0.1', '::1'],
all: ['true', 'false'],
n: [5e6]
n: [5e6],
});

function main({ name, n, all }) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/domain/domain-fn-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const domain = require('domain');

const bench = common.createBenchmark(main, {
args: [0, 1, 2, 3],
n: [10]
n: [10],
});

const bdomain = domain.create();
Expand Down
4 changes: 2 additions & 2 deletions benchmark/error/node-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ const common = require('../common');
const bench = common.createBenchmark(main, {
n: [1e7],
}, {
flags: ['--expose-internals']
flags: ['--expose-internals'],
});

function main({ n }) {
const {
codes: {
ERR_INVALID_STATE,
}
},
} = require('internal/errors');
bench.start();
for (let i = 0; i < n; ++i)
Expand Down
2 changes: 1 addition & 1 deletion benchmark/es/defaultparams-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const assert = require('assert');

const bench = common.createBenchmark(main, {
method: ['withoutdefaults', 'withdefaults'],
n: [1e8]
n: [1e8],
});

function oldStyleDefaults(x, y) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/es/destructuring-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const assert = require('assert');

const bench = common.createBenchmark(main, {
method: ['swap', 'destructure'],
n: [1e8]
n: [1e8],
});

function runSwapManual(n) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/es/destructuring-object-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const common = require('../common.js');

const bench = common.createBenchmark(main, {
method: ['normal', 'destructureObject'],
n: [1e8]
n: [1e8],
});

function runNormal(n) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/es/foreach-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, {
method: ['for', 'for-of', 'for-in', 'forEach'],
count: [5, 10, 20, 100],
n: [5e6]
n: [5e6],
});

function useFor(n, items, count) {
Expand Down
4 changes: 2 additions & 2 deletions benchmark/es/map-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
'object', 'nullProtoObject', 'nullProtoLiteralObject', 'storageObject',
'fakeMap', 'map',
],
n: [1e6]
n: [1e6],
});

function runObject(n) {
Expand Down Expand Up @@ -72,7 +72,7 @@ function fakeMap() {
get(key) { return m[`$${key}`]; },
set(key, val) { m[`$${key}`] = val; },
get size() { return Object.keys(m).length; },
has(key) { return Object.hasOwn(m, `$${key}`); }
has(key) { return Object.hasOwn(m, `$${key}`); },
};
}

Expand Down
2 changes: 1 addition & 1 deletion benchmark/es/restparams-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const assert = require('assert');

const bench = common.createBenchmark(main, {
method: ['copy', 'rest', 'arguments'],
n: [1e8]
n: [1e8],
});

function copyArguments() {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/es/spread-assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const util = require('util');
const bench = common.createBenchmark(main, {
method: ['spread', 'assign', '_extend'],
count: [5, 10, 20],
n: [1e6]
n: [1e6],
});

function main({ n, context, count, rest, method }) {
Expand Down
Loading

0 comments on commit e028a28

Please sign in to comment.