Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark: clean up config resolution in multiple benchmarks #31581

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions benchmark/fs/readfile-partitioned.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ const bench = common.createBenchmark(main, {
concurrent: [1, 10]
});

function main(conf) {
const len = +conf.len;
function main({ len, dur, concurrent }) {
try { fs.unlinkSync(filename); } catch {}
let data = Buffer.alloc(len, 'x');
fs.writeFileSync(filename, data);
Expand All @@ -40,7 +39,7 @@ function main(conf) {
benchEnded = true;
bench.end(totalOps);
try { fs.unlinkSync(filename); } catch {}
}, +conf.dur * 1000);
}, dur * 1000);

function read() {
fs.readFile(filename, afterRead);
Expand Down Expand Up @@ -78,8 +77,7 @@ function main(conf) {
}

// Start reads
let cur = +conf.concurrent;
while (cur--) read();
while (concurrent-- > 0) read();

// Start a competing zip
zip();
Expand Down
5 changes: 1 addition & 4 deletions benchmark/http/set_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ const bench = common.createBenchmark(main, {
n: [1e6],
});

function main(conf) {
const n = +conf.n;
const value = conf.value;

function main({ n, value }) {
const og = new OutgoingMessage();

bench.start();
Expand Down
5 changes: 2 additions & 3 deletions benchmark/url/legacy-vs-whatwg-url-get-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ function useWHATWG(data) {
}

function main({ type, method, e }) {
e = +e;
var data;
var noDead; // Avoid dead code elimination.
let data;
let noDead; // Avoid dead code elimination.
switch (method) {
case 'legacy':
data = common.bakeUrlData(type, e, false, false);
Expand Down
1 change: 0 additions & 1 deletion benchmark/url/legacy-vs-whatwg-url-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ function useWHATWGWithoutBase(data) {
}

function main({ e, method, type, withBase }) {
e = +e;
withBase = withBase === 'true';
var noDead; // Avoid dead code elimination.
var data;
Expand Down
1 change: 0 additions & 1 deletion benchmark/url/legacy-vs-whatwg-url-serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ function useWHATWG(data) {
}

function main({ type, e, method }) {
e = +e;
const data = common.bakeUrlData(type, e, false, false);

var noDead; // Avoid dead code elimination.
Expand Down
1 change: 0 additions & 1 deletion benchmark/url/whatwg-url-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ function get(data, prop) {
}

function main({ e, type, prop, withBase }) {
e = +e;
withBase = withBase === 'true';
const data = common.bakeUrlData(type, e, withBase, true);
switch (prop) {
Expand Down
18 changes: 7 additions & 11 deletions benchmark/worker/echo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const common = require('../common.js');
const { Worker } = require('worker_threads');
const path = require('path');
const bench = common.createBenchmark(main, {
workers: [1],
Expand All @@ -11,19 +12,14 @@ const bench = common.createBenchmark(main, {

const workerPath = path.resolve(__dirname, '..', 'fixtures', 'echo.worker.js');

function main(conf) {
const { Worker } = require('worker_threads');

const n = +conf.n;
const workers = +conf.workers;
const sends = +conf.sendsPerBroadcast;
function main({ n, workers, sendsPerBroadcast: sends, payload: payloadType }) {
const expectedPerBroadcast = sends * workers;
var payload;
var readies = 0;
var broadcasts = 0;
var msgCount = 0;
let payload;
let readies = 0;
let broadcasts = 0;
let msgCount = 0;

switch (conf.payload) {
switch (payloadType) {
case 'string':
payload = 'hello world!';
break;
Expand Down