benchmark: add trailing commas

PR-URL: https://github.com/nodejs/node/pull/46370
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Antoine du Hamel 2023-01-29 20:13:35 +02:00 committed by GitHub
parent 9954052d08
commit ca5f322d32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
84 changed files with 134 additions and 116 deletions

View file

@ -5,11 +5,29 @@ env:
es6: true es6: true
rules: rules:
comma-dangle: [error, {
arrays: always-multiline,
exports: always-multiline,
functions: only-multiline,
imports: always-multiline,
objects: only-multiline,
}]
prefer-arrow-callback: error 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,
}]

View file

@ -106,7 +106,7 @@ class TestDoubleBenchmarker {
const scheme = options.scheme || 'http'; const scheme = options.scheme || 'http';
const env = { const env = {
test_url: `${scheme}://127.0.0.1:${options.port}${options.path}`, test_url: `${scheme}://127.0.0.1:${options.port}${options.path}`,
...process.env ...process.env,
}; };
const child = child_process.fork(this.executable, const child = child_process.fork(this.executable,
@ -203,7 +203,7 @@ exports.run = function(options, callback) {
connections: 100, connections: 100,
duration: 5, duration: 5,
benchmarker: exports.default_http_benchmarker, benchmarker: exports.default_http_benchmarker,
...options ...options,
}; };
if (!options.benchmarker) { if (!options.benchmarker) {
callback(new Error('Could not locate required http benchmarker. See ' + callback(new Error('Could not locate required http benchmarker. See ' +

View file

@ -46,7 +46,7 @@ function main({ n, len, method, strict }) {
} }
case 'deepEqual_mixed': { case 'deepEqual_mixed': {
const values = array.map( 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); benchmark(strict ? deepStrictEqual : deepEqual, n, values);
break; break;
@ -67,7 +67,7 @@ function main({ n, len, method, strict }) {
} }
case 'notDeepEqual_mixed': { case 'notDeepEqual_mixed': {
const values = array.map( 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); const values2 = values.slice(0);
values2[0] = ['w00t', 123]; values2[0] = ['w00t', 123];

View file

@ -5,7 +5,7 @@ const { Blob } = require('buffer');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
bytes: [128, 1024, 1024 ** 2], bytes: [128, 1024, 1024 ** 2],
n: [1e6], n: [1e6],
operation: ['text', 'arrayBuffer'] operation: ['text', 'arrayBuffer'],
}); });
async function run(n, bytes, operation) { async function run(n, bytes, operation) {

View file

@ -5,7 +5,7 @@ const { File } = require('buffer');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
bytes: [128, 1024, 1024 ** 2], bytes: [128, 1024, 1024 ** 2],
n: [1e6], n: [1e6],
operation: ['text', 'arrayBuffer'] operation: ['text', 'arrayBuffer'],
}); });
const options = { const options = {

View file

@ -9,7 +9,7 @@ if (!isWindows) messagesLength.push(32768);
const bench = common.createBenchmark(childProcessExecStdout, { const bench = common.createBenchmark(childProcessExecStdout, {
len: messagesLength, len: messagesLength,
dur: [5] dur: [5],
}); });
function childProcessExecStdout({ dur, len }) { function childProcessExecStdout({ dur, len }) {

View file

@ -15,7 +15,7 @@ if (process.argv[2] === 'child') {
64, 256, 1024, 4096, 16384, 65536, 64, 256, 1024, 4096, 16384, 65536,
65536 << 4, 65536 << 6 - 1, 65536 << 4, 65536 << 6 - 1,
], ],
dur: [5] dur: [5],
}); });
const spawn = require('child_process').spawn; const spawn = require('child_process').spawn;

View file

@ -14,7 +14,7 @@ if (os.platform() !== 'win32')
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
len: messagesLength, len: messagesLength,
dur: [5] dur: [5],
}); });
function main({ dur, len }) { function main({ dur, len }) {

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const common = require('../common.js'); const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1000] n: [1000],
}); });
const spawn = require('child_process').spawn; const spawn = require('child_process').spawn;

View file

@ -8,7 +8,7 @@ if (cluster.isMaster) {
payload: ['string', 'object'], payload: ['string', 'object'],
sendsPerBroadcast: [1, 10], sendsPerBroadcast: [1, 10],
serialization: ['json', 'advanced'], serialization: ['json', 'advanced'],
n: [1e5] n: [1e5],
}); });
function main({ function main({
@ -16,7 +16,7 @@ if (cluster.isMaster) {
workers, workers,
sendsPerBroadcast, sendsPerBroadcast,
payload, payload,
serialization serialization,
}) { }) {
const expectedPerBroadcast = sendsPerBroadcast * workers; const expectedPerBroadcast = sendsPerBroadcast * workers;
let readies = 0; let readies = 0;

View file

@ -108,7 +108,7 @@ class Benchmark {
cliOptions[key] = []; cliOptions[key] = [];
cliOptions[key].push( cliOptions[key].push(
// Infer the type from the config object and parse accordingly // 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 { } else {
extraOptions[key] = value; extraOptions[key] = value;
@ -148,7 +148,7 @@ class Benchmark {
const allowed = combinationFilter({ ...currConfig }); const allowed = combinationFilter({ ...currConfig });
if (typeof allowed !== 'boolean') { if (typeof allowed !== 'boolean') {
throw new TypeError( throw new TypeError(
'Combination filter must always return a boolean' 'Combination filter must always return a boolean',
); );
} }
if (allowed) if (allowed)
@ -183,7 +183,7 @@ class Benchmark {
} }
this.config.benchmarker = used_benchmarker; this.config.benchmarker = used_benchmarker;
this.report(result, elapsed); this.report(result, elapsed);
} },
); );
} }

View file

@ -71,7 +71,7 @@ if (showProgress) {
const job = queue[i]; const job = queue[i];
const child = fork(path.resolve(__dirname, job.filename), cli.optional.set, { 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) => { child.on('message', (data) => {

View file

@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {
num: [100], num: [100],
chunks: [1, 2, 4, 8], chunks: [1, 2, 4, 8],
type: ['concat', 'multi'], type: ['concat', 'multi'],
dur: [5] dur: [5],
}); });
function main({ dur, len, num, type, chunks }) { function main({ dur, len, num, type, chunks }) {

View file

@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {
num: [100], num: [100],
chunks: [1, 2, 4, 8], chunks: [1, 2, 4, 8],
type: ['send', 'recv'], type: ['send', 'recv'],
dur: [5] dur: [5],
}); });
function main({ dur, len, num, type, chunks }) { function main({ dur, len, num, type, chunks }) {

View file

@ -12,7 +12,7 @@ const bench = common.createBenchmark(main, {
len: [1, 64, 256, 1024], len: [1, 64, 256, 1024],
num: [100], num: [100],
type: ['send', 'recv'], type: ['send', 'recv'],
dur: [5] dur: [5],
}); });
function main({ dur, len, num, type }) { function main({ dur, len, num, type }) {

View file

@ -12,7 +12,7 @@ const bench = common.createBenchmark(main, {
len: [1, 64, 256, 1024], len: [1, 64, 256, 1024],
num: [100], num: [100],
type: ['send', 'recv'], type: ['send', 'recv'],
dur: [5] dur: [5],
}); });
function main({ dur, len, num, type }) { function main({ dur, len, num, type }) {

View file

@ -11,7 +11,7 @@ const bench = common.createBenchmark(main, {
chunks: 4, chunks: 4,
connections: [50, 500], connections: [50, 500],
chunkedEnc: 1, chunkedEnc: 1,
duration: 5 duration: 5,
}); });
function main({ apm, connections, duration, type, len, chunks, chunkedEnc }) { function main({ apm, connections, duration, type, len, chunks, chunkedEnc }) {
@ -24,7 +24,7 @@ function main({ apm, connections, duration, type, len, chunks, chunkedEnc }) {
bench.http({ bench.http({
path, path,
connections, connections,
duration duration,
}, () => { }, () => {
server.close(); server.close();
if (done) done(); if (done) done();
@ -44,14 +44,14 @@ function patch() {
if (name === 'request') { if (name === 'request') {
als.enterWith({ als.enterWith({
url: req.url, url: req.url,
start: process.hrtime.bigint() start: process.hrtime.bigint(),
}); });
res.on('finish', () => { res.on('finish', () => {
times.push({ times.push({
...als.getStore(), ...als.getStore(),
statusCode: res.statusCode, statusCode: res.statusCode,
end: process.hrtime.bigint() end: process.hrtime.bigint(),
}); });
}); });
} }
@ -74,7 +74,7 @@ function diagnostics_channel() {
function onStart(req) { function onStart(req) {
als.enterWith({ als.enterWith({
url: req.url, url: req.url,
start: process.hrtime.bigint() start: process.hrtime.bigint(),
}); });
} }
@ -82,7 +82,7 @@ function diagnostics_channel() {
times.push({ times.push({
...als.getStore(), ...als.getStore(),
statusCode: res.statusCode, statusCode: res.statusCode,
end: process.hrtime.bigint() end: process.hrtime.bigint(),
}); });
} }

View file

@ -16,7 +16,7 @@ function main({ n, subscribers }) {
} }
const data = { const data = {
foo: 'bar' foo: 'bar',
}; };
bench.start(); bench.start();

View file

@ -6,7 +6,7 @@ const { lookup } = require('dns').promises;
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
name: ['127.0.0.1', '::1'], name: ['127.0.0.1', '::1'],
all: ['true', 'false'], all: ['true', 'false'],
n: [5e6] n: [5e6],
}); });
function main({ name, n, all }) { function main({ name, n, all }) {

View file

@ -6,7 +6,7 @@ const lookup = require('dns').lookup;
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
name: ['127.0.0.1', '::1'], name: ['127.0.0.1', '::1'],
all: ['true', 'false'], all: ['true', 'false'],
n: [5e6] n: [5e6],
}); });
function main({ name, n, all }) { function main({ name, n, all }) {

View file

@ -4,7 +4,7 @@ const domain = require('domain');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
args: [0, 1, 2, 3], args: [0, 1, 2, 3],
n: [10] n: [10],
}); });
const bdomain = domain.create(); const bdomain = domain.create();

View file

@ -5,14 +5,14 @@ const common = require('../common');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1e7], n: [1e7],
}, { }, {
flags: ['--expose-internals'] flags: ['--expose-internals'],
}); });
function main({ n }) { function main({ n }) {
const { const {
codes: { codes: {
ERR_INVALID_STATE, ERR_INVALID_STATE,
} },
} = require('internal/errors'); } = require('internal/errors');
bench.start(); bench.start();
for (let i = 0; i < n; ++i) for (let i = 0; i < n; ++i)

View file

@ -5,7 +5,7 @@ const assert = require('assert');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
method: ['withoutdefaults', 'withdefaults'], method: ['withoutdefaults', 'withdefaults'],
n: [1e8] n: [1e8],
}); });
function oldStyleDefaults(x, y) { function oldStyleDefaults(x, y) {

View file

@ -5,7 +5,7 @@ const assert = require('assert');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
method: ['swap', 'destructure'], method: ['swap', 'destructure'],
n: [1e8] n: [1e8],
}); });
function runSwapManual(n) { function runSwapManual(n) {

View file

@ -4,7 +4,7 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
method: ['normal', 'destructureObject'], method: ['normal', 'destructureObject'],
n: [1e8] n: [1e8],
}); });
function runNormal(n) { function runNormal(n) {

View file

@ -5,7 +5,7 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
method: ['for', 'for-of', 'for-in', 'forEach'], method: ['for', 'for-of', 'for-in', 'forEach'],
count: [5, 10, 20, 100], count: [5, 10, 20, 100],
n: [5e6] n: [5e6],
}); });
function useFor(n, items, count) { function useFor(n, items, count) {

View file

@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
'object', 'nullProtoObject', 'nullProtoLiteralObject', 'storageObject', 'object', 'nullProtoObject', 'nullProtoLiteralObject', 'storageObject',
'fakeMap', 'map', 'fakeMap', 'map',
], ],
n: [1e6] n: [1e6],
}); });
function runObject(n) { function runObject(n) {
@ -72,7 +72,7 @@ function fakeMap() {
get(key) { return m[`$${key}`]; }, get(key) { return m[`$${key}`]; },
set(key, val) { m[`$${key}`] = val; }, set(key, val) { m[`$${key}`] = val; },
get size() { return Object.keys(m).length; }, get size() { return Object.keys(m).length; },
has(key) { return Object.hasOwn(m, `$${key}`); } has(key) { return Object.hasOwn(m, `$${key}`); },
}; };
} }

View file

@ -5,7 +5,7 @@ const assert = require('assert');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
method: ['copy', 'rest', 'arguments'], method: ['copy', 'rest', 'arguments'],
n: [1e8] n: [1e8],
}); });
function copyArguments() { function copyArguments() {

View file

@ -6,7 +6,7 @@ const util = require('util');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
method: ['spread', 'assign', '_extend'], method: ['spread', 'assign', '_extend'],
count: [5, 10, 20], count: [5, 10, 20],
n: [1e6] n: [1e6],
}); });
function main({ n, context, count, rest, method }) { function main({ n, context, count, rest, method }) {

View file

@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
count: [5, 10, 20], count: [5, 10, 20],
context: ['context', 'null'], context: ['context', 'null'],
rest: [0, 1], rest: [0, 1],
n: [5e6] n: [5e6],
}); });
function makeTest(count, rest) { function makeTest(count, rest) {

View file

@ -9,7 +9,7 @@ const benchmarkDirectory =
path.resolve(tmpdir.path, 'benchmark-esm-parse'); path.resolve(tmpdir.path, 'benchmark-esm-parse');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1e2] n: [1e2],
}); });
async function main({ n }) { async function main({ n }) {

View file

@ -5,7 +5,7 @@ const EventEmitter = require('events').EventEmitter;
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [5e6], n: [5e6],
listeners: [5, 50], listeners: [5, 50],
raw: ['true', 'false'] raw: ['true', 'false'],
}); });
function main({ n, listeners, raw }) { function main({ n, listeners, raw }) {

View file

@ -4,7 +4,7 @@ const EventEmitter = require('events').EventEmitter;
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [2e7], n: [2e7],
argc: [0, 1, 4, 5] argc: [0, 1, 4, 5],
}); });
function main({ n, argc }) { function main({ n, argc }) {

View file

@ -3,7 +3,7 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1e6], n: [1e6],
listeners: [1, 5, 10] listeners: [1, 5, 10],
}, { flags: ['--expose-internals'] }); }, { flags: ['--expose-internals'] });
function main({ n, listeners }) { function main({ n, listeners }) {

View file

@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
c: [50, 500], c: [50, 500],
chunkedEnc: [1, 0], chunkedEnc: [1, 0],
benchmarker: ['test-double-https'], benchmarker: ['test-double-https'],
duration: 5 duration: 5,
}); });
function main({ type, len, chunks, c, chunkedEnc, duration }) { function main({ type, len, chunks, c, chunkedEnc, duration }) {
@ -21,7 +21,7 @@ function main({ type, len, chunks, c, chunkedEnc, duration }) {
path, path,
connections: c, connections: c,
scheme: 'https', scheme: 'https',
duration duration,
}, () => { }, () => {
server.close(); server.close();
}); });

View file

@ -38,7 +38,7 @@ assert(js() === cxx());
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
type: ['js', 'cxx', 'napi'], type: ['js', 'cxx', 'napi'],
n: [1e6, 1e7, 5e7] n: [1e6, 1e7, 5e7],
}); });
function main({ n, type }) { function main({ n, type }) {

View file

@ -4,7 +4,7 @@ const common = require('../common.js');
const cpus = require('os').cpus; const cpus = require('os').cpus;
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [3e4] n: [3e4],
}); });
function main({ n }) { function main({ n }) {

View file

@ -4,7 +4,7 @@ const common = require('../common.js');
const loadavg = require('os').loadavg; const loadavg = require('os').loadavg;
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [5e6] n: [5e6],
}); });
function main({ n }) { function main({ n }) {

View file

@ -4,7 +4,7 @@ const common = require('../common.js');
const networkInterfaces = require('os').networkInterfaces; const networkInterfaces = require('os').networkInterfaces;
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1e4] n: [1e4],
}); });
function main({ n }) { function main({ n }) {

View file

@ -18,7 +18,7 @@ function createTimingInfo({
endTime = 0, endTime = 0,
encodedBodySize = 0, encodedBodySize = 0,
decodedBodySize = 0, decodedBodySize = 0,
finalConnectionTimingInfo = null finalConnectionTimingInfo = null,
}) { }) {
if (finalConnectionTimingInfo !== null) { if (finalConnectionTimingInfo !== null) {
finalConnectionTimingInfo.domainLookupStartTime = finalConnectionTimingInfo.domainLookupStartTime =
@ -61,7 +61,7 @@ function test() {
'http://localhost:8080', 'http://localhost:8080',
'fetch', 'fetch',
{}, {},
'' '',
); );
} }

View file

@ -4,11 +4,11 @@
const common = require('../common.js'); const common = require('../common.js');
const configs = { const configs = {
n: [1024] n: [1024],
}; };
const options = { const options = {
flags: ['--expose-internals'] flags: ['--expose-internals'],
}; };
const bench = common.createBenchmark(main, configs, options); const bench = common.createBenchmark(main, configs, options);
@ -25,12 +25,12 @@ function main(conf) {
integrity: `sha256-${hash(`// ./_${i}`, 'sha256')}`, integrity: `sha256-${hash(`// ./_${i}`, 'sha256')}`,
dependencies: Object.fromEntries(Array.from({ dependencies: Object.fromEntries(Array.from({
// Average 3 deps per 4 modules // Average 3 deps per 4 modules
length: Math.floor((i % 4) / 2) length: Math.floor((i % 4) / 2),
}, (_, ii) => { }, (_, ii) => {
return [`_${ii}`, `./_${i - ii}`]; return [`_${ii}`, `./_${i - ii}`];
})), })),
}]; }];
}) }),
); );
const json = JSON.parse(JSON.stringify({ resources }), (_, o) => { const json = JSON.parse(JSON.stringify({ resources }), (_, o) => {
if (o && typeof o === 'object') { if (o && typeof o === 'object') {

View file

@ -12,22 +12,22 @@ function main({ type, n }) {
noencode: { noencode: {
foo: 'bar', foo: 'bar',
baz: 'quux', baz: 'quux',
xyzzy: 'thud' xyzzy: 'thud',
}, },
encodemany: { encodemany: {
'\u0080\u0083\u0089': 'bar', '\u0080\u0083\u0089': 'bar',
'\u008C\u008E\u0099': 'quux', '\u008C\u008E\u0099': 'quux',
'xyzzy': '\u00A5q\u00A3r' 'xyzzy': '\u00A5q\u00A3r',
}, },
encodelast: { encodelast: {
foo: 'bar', foo: 'bar',
baz: 'quux', baz: 'quux',
xyzzy: 'thu\u00AC' xyzzy: 'thu\u00AC',
}, },
array: { array: {
foo: [], foo: [],
baz: ['bar'], baz: ['bar'],
xyzzy: ['bar', 'quux', 'thud'] xyzzy: ['bar', 'quux', 'thud'],
}, },
multiprimitives: { multiprimitives: {
foo: false, foo: false,

View file

@ -27,7 +27,7 @@ function getLoremIpsumStream(repetitions) {
}); });
let i = 0; let i = 0;
readable._read = () => readable.push( readable._read = () => readable.push(
i++ >= repetitions ? null : loremIpsum i++ >= repetitions ? null : loremIpsum,
); );
return readable; return readable;
} }

View file

@ -42,7 +42,7 @@ if (format === 'csv') {
const filename = benchmarks[i]; const filename = benchmarks[i];
const child = fork( const child = fork(
path.resolve(__dirname, filename), path.resolve(__dirname, filename),
cli.test ? ['--test'] : cli.optional.set cli.test ? ['--test'] : cli.optional.set,
); );
if (format !== 'csv') { if (format !== 'csv') {

View file

@ -9,7 +9,7 @@ const {
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [50e6], n: [50e6],
kind: ['duplex', 'readable', 'transform', 'writable'] kind: ['duplex', 'readable', 'transform', 'writable'],
}); });
function main({ n, kind }) { function main({ n, kind }) {

View file

@ -9,7 +9,7 @@ const {
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1e6], n: [1e6],
kind: ['duplex', 'readable', 'transform', 'writable'] kind: ['duplex', 'readable', 'transform', 'writable'],
}); });
function main({ n, kind }) { function main({ n, kind }) {

View file

@ -4,7 +4,7 @@ const common = require('../common');
const { Readable, Writable } = require('stream'); const { Readable, Writable } = require('stream');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [5e6] n: [5e6],
}); });
function main({ n }) { function main({ n }) {

View file

@ -4,7 +4,7 @@ const common = require('../common');
const { Readable, Writable } = require('stream'); const { Readable, Writable } = require('stream');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [5e6] n: [5e6],
}); });
function main({ n }) { function main({ n }) {

View file

@ -21,7 +21,7 @@ async function main({ n, sync }) {
this.push(1); this.push(1);
}); });
} }
} },
}); });
bench.start(); bench.start();

View file

@ -4,7 +4,7 @@ const common = require('../common');
const Readable = require('stream').Readable; const Readable = require('stream').Readable;
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1e3] n: [1e3],
}); });
function main({ n }) { function main({ n }) {

View file

@ -4,7 +4,7 @@ const common = require('../common');
const Readable = require('stream').Readable; const Readable = require('stream').Readable;
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1e3] n: [1e3],
}); });
function main({ n }) { function main({ n }) {

View file

@ -5,7 +5,7 @@ const Readable = require('stream').Readable;
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [200e1], n: [200e1],
type: ['string', 'buffer'] type: ['string', 'buffer'],
}); });
function main({ n, type }) { function main({ n, type }) {

View file

@ -4,7 +4,7 @@ const common = require('../common');
const Readable = require('stream').Readable; const Readable = require('stream').Readable;
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [50e2] n: [50e2],
}); });
function main({ n }) { function main({ n }) {

View file

@ -4,7 +4,7 @@ const common = require('../common');
const Readable = require('stream').Readable; const Readable = require('stream').Readable;
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1e3] n: [1e3],
}); });
function main({ n }) { function main({ n }) {

View file

@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
sync: ['yes', 'no'], sync: ['yes', 'no'],
writev: ['yes', 'no'], writev: ['yes', 'no'],
callback: ['yes', 'no'], callback: ['yes', 'no'],
len: [1024, 32 * 1024] len: [1024, 32 * 1024],
}); });
function main({ n, sync, writev, callback, len }) { function main({ n, sync, writev, callback, len }) {

View file

@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
encoding: [ encoding: [
'ascii', 'utf8', 'utf-8', 'base64', 'ucs2', 'UTF-8', 'AscII', 'UTF-16LE', 'ascii', 'utf8', 'utf-8', 'base64', 'ucs2', 'UTF-8', 'AscII', 'UTF-16LE',
], ],
n: [25e6] n: [25e6],
}); });
function main({ encoding, n }) { function main({ encoding, n }) {

View file

@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
encoding: ['ascii', 'utf8', 'base64-utf8', 'base64-ascii', 'utf16le'], encoding: ['ascii', 'utf8', 'base64-utf8', 'base64-ascii', 'utf16le'],
inLen: [32, 128, 1024, 4096], inLen: [32, 128, 1024, 4096],
chunkLen: [16, 64, 256, 1024], chunkLen: [16, 64, 256, 1024],
n: [25e5] n: [25e5],
}); });
const UTF8_ALPHA = 'Blåbærsyltetøy'; const UTF8_ALPHA = 'Blåbærsyltetøy';

View file

@ -3,7 +3,7 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [5e6], n: [5e6],
type: ['depth', 'depth1', 'breadth', 'breadth1', 'breadth4', 'clear'] type: ['depth', 'depth1', 'breadth', 'breadth1', 'breadth4', 'clear'],
}); });
function main({ n, type }) { function main({ n, type }) {

View file

@ -2,7 +2,7 @@
const common = require('../common.js'); const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [5e6] n: [5e6],
}); });
function main({ n }) { function main({ n }) {

View file

@ -2,7 +2,7 @@
const common = require('../common.js'); const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1e7] n: [1e7],
}); });
function main({ n }) { function main({ n }) {

View file

@ -2,7 +2,7 @@
const common = require('../common.js'); const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [5e6] n: [5e6],
}); });
function main({ n }) { function main({ n }) {

View file

@ -4,7 +4,7 @@ const assert = require('assert');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1e6], n: [1e6],
direction: ['start', 'end'] direction: ['start', 'end'],
}); });
function main({ n, direction }) { function main({ n, direction }) {

View file

@ -4,7 +4,7 @@ const assert = require('assert');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1e6], n: [1e6],
direction: ['start', 'end'] direction: ['start', 'end'],
}); });
function main({ direction, n }) { function main({ direction, n }) {

View file

@ -4,7 +4,7 @@ const common = require('../common.js');
const tls = require('tls'); const tls = require('tls');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1, 50000] n: [1, 50000],
}); });
function main({ n }) { function main({ n }) {

View file

@ -3,9 +3,9 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
dur: [5], dur: [5],
securing: ['SecurePair', 'TLSSocket', 'clear'], securing: ['SecurePair', 'TLSSocket', 'clear'],
size: [100, 1024, 1024 * 1024] size: [100, 1024, 1024 * 1024],
}, { }, {
flags: ['--no-warnings'] flags: ['--no-warnings'],
}); });
const fixtures = require('../../test/common/fixtures'); const fixtures = require('../../test/common/fixtures');

View file

@ -3,7 +3,7 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
dur: [5], dur: [5],
type: ['buf', 'asc', 'utf'], type: ['buf', 'asc', 'utf'],
size: [100, 1024, 1024 * 1024, 4 * 1024 * 1024, 16 * 1024 * 1024] size: [100, 1024, 1024 * 1024, 4 * 1024 * 1024, 16 * 1024 * 1024],
}); });
const fixtures = require('../../test/common/fixtures'); const fixtures = require('../../test/common/fixtures');

View file

@ -5,7 +5,7 @@ const bench = common.createBenchmark(main, {
type: ['buf', 'asc', 'utf'], type: ['buf', 'asc', 'utf'],
sendchunklen: [256, 32 * 1024, 128 * 1024, 16 * 1024 * 1024], sendchunklen: [256, 32 * 1024, 128 * 1024, 16 * 1024 * 1024],
recvbuflen: [0, 64 * 1024, 1024 * 1024], recvbuflen: [0, 64 * 1024, 1024 * 1024],
recvbufgenfn: ['true', 'false'] recvbufgenfn: ['true', 'false'],
}); });
const fixtures = require('../../test/common/fixtures'); const fixtures = require('../../test/common/fixtures');
@ -68,8 +68,8 @@ function main({ dur, type, sendchunklen, recvbuflen, recvbufgenfn }) {
buffer, buffer,
callback: function(nread, buf) { callback: function(nread, buf) {
received += nread; received += nread;
} },
} },
}; };
} }

View file

@ -5,7 +5,7 @@ const tls = require('tls');
const common = require('../common.js'); const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
concurrency: [1, 10], concurrency: [1, 10],
dur: [5] dur: [5],
}); });
let clientConn = 0; let clientConn = 0;
@ -43,7 +43,7 @@ function onConnection(conn) {
function makeConnection() { function makeConnection() {
const options = { const options = {
port: common.PORT, port: common.PORT,
rejectUnauthorized: false rejectUnauthorized: false,
}; };
const conn = tls.connect(options, () => { const conn = tls.connect(options, () => {
clientConn++; clientConn++;

View file

@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
'getHeapStatistics', 'getHeapStatistics',
'getHeapSpaceStatistics', 'getHeapSpaceStatistics',
], ],
n: [1e6] n: [1e6],
}); });
function main({ method, n }) { function main({ method, n }) {

View file

@ -5,7 +5,7 @@ const v8 = require('v8');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
len: [256, 1024 * 16, 1024 * 512], len: [256, 1024 * 16, 1024 * 512],
n: [1e6] n: [1e6],
}); });
function main({ n, len }) { function main({ n, len }) {

View file

@ -3,7 +3,7 @@
const common = require('../common.js'); const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [100] n: [100],
}); });
const vm = require('vm'); const vm = require('vm');

View file

@ -5,7 +5,7 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1], n: [1],
breakOnSigint: [0, 1], breakOnSigint: [0, 1],
withSigintListener: [0, 1] withSigintListener: [0, 1],
}); });
const vm = require('vm'); const vm = require('vm');

View file

@ -5,7 +5,7 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1], n: [1],
breakOnSigint: [0, 1], breakOnSigint: [0, 1],
withSigintListener: [0, 1] withSigintListener: [0, 1],
}); });
const vm = require('vm'); const vm = require('vm');

View file

@ -9,7 +9,7 @@ const assert = require('assert');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [50e3], n: [50e3],
kind: ['ReadableStream', 'TransformStream', 'WritableStream'] kind: ['ReadableStream', 'TransformStream', 'WritableStream'],
}); });
let rs, ws, ts; let rs, ws, ts;

View file

@ -23,7 +23,7 @@ async function main({ n, highWaterMarkR, highWaterMarkW }) {
} else { } else {
controller.close(); controller.close();
} }
} },
}); });
const ws = new WritableStream({ const ws = new WritableStream({
highWaterMark: highWaterMarkW, highWaterMark: highWaterMarkW,

View file

@ -13,7 +13,7 @@ async function main({ n }) {
const rs = new ReadableStream({ const rs = new ReadableStream({
pull: function(controller) { pull: function(controller) {
controller.enqueue(1); controller.enqueue(1);
} },
}); });
let x = 0; let x = 0;

View file

@ -3,7 +3,7 @@
const common = require('../common.js'); const common = require('../common.js');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
n: [1e7] n: [1e7],
}); });
function main({ n }) { function main({ n }) {

View file

@ -7,7 +7,7 @@ const bench = common.createBenchmark(main, {
workers: [1], workers: [1],
payload: ['string', 'object'], payload: ['string', 'object'],
sendsPerBroadcast: [1, 10], sendsPerBroadcast: [1, 10],
n: [1e5] n: [1e5],
}); });
const workerPath = path.resolve(__dirname, '..', 'fixtures', 'echo.worker.js'); const workerPath = path.resolve(__dirname, '..', 'fixtures', 'echo.worker.js');

View file

@ -5,7 +5,7 @@ const { MessageChannel } = require('worker_threads');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
payload: ['string', 'object'], payload: ['string', 'object'],
style: ['eventtarget', 'eventemitter'], style: ['eventtarget', 'eventemitter'],
n: [1e6] n: [1e6],
}); });
function main(conf) { function main(conf) {

View file

@ -5,7 +5,7 @@ const zlib = require('zlib');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
inputLen: [16 * 1024 * 1024], inputLen: [16 * 1024 * 1024],
chunkLen: [1024], chunkLen: [1024],
n: [1e2] n: [1e2],
}); });
function main({ n, inputLen, chunkLen }) { function main({ n, inputLen, chunkLen }) {

View file

@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
'BrotliCompress', 'BrotliDecompress', 'BrotliCompress', 'BrotliDecompress',
], ],
options: ['true', 'false'], options: ['true', 'false'],
n: [5e5] n: [5e5],
}); });
function main({ n, type, options }) { function main({ n, type, options }) {

View file

@ -5,7 +5,7 @@ const zlib = require('zlib');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
method: ['createDeflate', 'deflate', 'deflateSync'], method: ['createDeflate', 'deflate', 'deflateSync'],
inputLen: [1024], inputLen: [1024],
n: [4e5] n: [4e5],
}); });
function main({ n, method, inputLen }) { function main({ n, method, inputLen }) {

View file

@ -5,7 +5,7 @@ const zlib = require('zlib');
const bench = common.createBenchmark(main, { const bench = common.createBenchmark(main, {
method: ['inflate', 'inflateSync'], method: ['inflate', 'inflateSync'],
inputLen: [1024], inputLen: [1024],
n: [4e5] n: [4e5],
}); });
function main({ n, method, inputLen }) { function main({ n, method, inputLen }) {

View file

@ -7,12 +7,12 @@ const bench = common.createBenchmark(main, {
inputLen: [1024], inputLen: [1024],
duration: [5], duration: [5],
type: ['string', 'buffer'], type: ['string', 'buffer'],
algorithm: ['gzip', 'brotli'] algorithm: ['gzip', 'brotli'],
}, { }, {
test: { test: {
inputLen: 1024, inputLen: 1024,
duration: 0.2 duration: 0.2,
} },
}); });
function main({ inputLen, duration, type, algorithm }) { function main({ inputLen, duration, type, algorithm }) {