mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
benchmark: clean up config resolution in multiple benchmarks
This removes 'to Number' casting in multiple benchmarks (which is handled by the benchmark runner) and cleans up some var usage in changed benchmarks. PR-URL: https://github.com/nodejs/node/pull/31581 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
committed by
Rich Trott
parent
dbaa4ca166
commit
f7a1ef6fb5
@@ -22,8 +22,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
concurrent: [1, 10]
|
concurrent: [1, 10]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ len, dur, concurrent }) {
|
||||||
const len = +conf.len;
|
|
||||||
try { fs.unlinkSync(filename); } catch {}
|
try { fs.unlinkSync(filename); } catch {}
|
||||||
let data = Buffer.alloc(len, 'x');
|
let data = Buffer.alloc(len, 'x');
|
||||||
fs.writeFileSync(filename, data);
|
fs.writeFileSync(filename, data);
|
||||||
@@ -40,7 +39,7 @@ function main(conf) {
|
|||||||
benchEnded = true;
|
benchEnded = true;
|
||||||
bench.end(totalOps);
|
bench.end(totalOps);
|
||||||
try { fs.unlinkSync(filename); } catch {}
|
try { fs.unlinkSync(filename); } catch {}
|
||||||
}, +conf.dur * 1000);
|
}, dur * 1000);
|
||||||
|
|
||||||
function read() {
|
function read() {
|
||||||
fs.readFile(filename, afterRead);
|
fs.readFile(filename, afterRead);
|
||||||
@@ -78,8 +77,7 @@ function main(conf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start reads
|
// Start reads
|
||||||
let cur = +conf.concurrent;
|
while (concurrent-- > 0) read();
|
||||||
while (cur--) read();
|
|
||||||
|
|
||||||
// Start a competing zip
|
// Start a competing zip
|
||||||
zip();
|
zip();
|
||||||
|
|||||||
@@ -16,10 +16,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6],
|
n: [1e6],
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, value }) {
|
||||||
const n = +conf.n;
|
|
||||||
const value = conf.value;
|
|
||||||
|
|
||||||
const og = new OutgoingMessage();
|
const og = new OutgoingMessage();
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
|
|||||||
@@ -71,9 +71,8 @@ function useWHATWG(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main({ type, method, e }) {
|
function main({ type, method, e }) {
|
||||||
e = +e;
|
let data;
|
||||||
var data;
|
let noDead; // Avoid dead code elimination.
|
||||||
var noDead; // Avoid dead code elimination.
|
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case 'legacy':
|
case 'legacy':
|
||||||
data = common.bakeUrlData(type, e, false, false);
|
data = common.bakeUrlData(type, e, false, false);
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ function useWHATWGWithoutBase(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main({ e, method, type, withBase }) {
|
function main({ e, method, type, withBase }) {
|
||||||
e = +e;
|
|
||||||
withBase = withBase === 'true';
|
withBase = withBase === 'true';
|
||||||
var noDead; // Avoid dead code elimination.
|
var noDead; // Avoid dead code elimination.
|
||||||
var data;
|
var data;
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ function useWHATWG(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main({ type, e, method }) {
|
function main({ type, e, method }) {
|
||||||
e = +e;
|
|
||||||
const data = common.bakeUrlData(type, e, false, false);
|
const data = common.bakeUrlData(type, e, false, false);
|
||||||
|
|
||||||
var noDead; // Avoid dead code elimination.
|
var noDead; // Avoid dead code elimination.
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ function get(data, prop) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main({ e, type, prop, withBase }) {
|
function main({ e, type, prop, withBase }) {
|
||||||
e = +e;
|
|
||||||
withBase = withBase === 'true';
|
withBase = withBase === 'true';
|
||||||
const data = common.bakeUrlData(type, e, withBase, true);
|
const data = common.bakeUrlData(type, e, withBase, true);
|
||||||
switch (prop) {
|
switch (prop) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
const { Worker } = require('worker_threads');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
workers: [1],
|
workers: [1],
|
||||||
@@ -11,19 +12,14 @@ const bench = common.createBenchmark(main, {
|
|||||||
|
|
||||||
const workerPath = path.resolve(__dirname, '..', 'fixtures', 'echo.worker.js');
|
const workerPath = path.resolve(__dirname, '..', 'fixtures', 'echo.worker.js');
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, workers, sendsPerBroadcast: sends, payload: payloadType }) {
|
||||||
const { Worker } = require('worker_threads');
|
|
||||||
|
|
||||||
const n = +conf.n;
|
|
||||||
const workers = +conf.workers;
|
|
||||||
const sends = +conf.sendsPerBroadcast;
|
|
||||||
const expectedPerBroadcast = sends * workers;
|
const expectedPerBroadcast = sends * workers;
|
||||||
var payload;
|
let payload;
|
||||||
var readies = 0;
|
let readies = 0;
|
||||||
var broadcasts = 0;
|
let broadcasts = 0;
|
||||||
var msgCount = 0;
|
let msgCount = 0;
|
||||||
|
|
||||||
switch (conf.payload) {
|
switch (payloadType) {
|
||||||
case 'string':
|
case 'string':
|
||||||
payload = 'hello world!';
|
payload = 'hello world!';
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user