benchmark: refactor _http-benchmarkers.js
Refactor _http-benchmarkers.js: * The file used a mixture of inline callbacks with the `function` keyword and arrow functions. Use arrow functions for consistency. * The file used a mixture of trailing commas and no trailing commas. Use trailing commas for consistency. PR-URL: https://github.com/nodejs/node/pull/25803 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
32c7ad6c67
commit
0fd6e64503
@ -25,7 +25,7 @@ class AutocannonBenchmarker {
|
|||||||
'-c', options.connections,
|
'-c', options.connections,
|
||||||
'-j',
|
'-j',
|
||||||
'-n',
|
'-n',
|
||||||
`http://127.0.0.1:${options.port}${options.path}`
|
`http://127.0.0.1:${options.port}${options.path}`,
|
||||||
];
|
];
|
||||||
const child = child_process.spawn(this.executable, args);
|
const child = child_process.spawn(this.executable, args);
|
||||||
return child;
|
return child;
|
||||||
@ -59,7 +59,7 @@ class WrkBenchmarker {
|
|||||||
'-d', options.duration,
|
'-d', options.duration,
|
||||||
'-c', options.connections,
|
'-c', options.connections,
|
||||||
'-t', 8,
|
'-t', 8,
|
||||||
`http://127.0.0.1:${options.port}${options.path}`
|
`http://127.0.0.1:${options.port}${options.path}`,
|
||||||
];
|
];
|
||||||
const child = child_process.spawn(this.executable, args);
|
const child = child_process.spawn(this.executable, args);
|
||||||
return child;
|
return child;
|
||||||
@ -170,7 +170,7 @@ const http_benchmarkers = [
|
|||||||
new AutocannonBenchmarker(),
|
new AutocannonBenchmarker(),
|
||||||
new TestDoubleBenchmarker('http'),
|
new TestDoubleBenchmarker('http'),
|
||||||
new TestDoubleBenchmarker('http2'),
|
new TestDoubleBenchmarker('http2'),
|
||||||
new H2LoadBenchmarker()
|
new H2LoadBenchmarker(),
|
||||||
];
|
];
|
||||||
|
|
||||||
const benchmarkers = {};
|
const benchmarkers = {};
|
||||||
@ -188,7 +188,7 @@ exports.run = function(options, callback) {
|
|||||||
path: '/',
|
path: '/',
|
||||||
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 ' +
|
||||||
@ -216,7 +216,7 @@ exports.run = function(options, callback) {
|
|||||||
let stdout = '';
|
let stdout = '';
|
||||||
child.stdout.on('data', (chunk) => stdout += chunk.toString());
|
child.stdout.on('data', (chunk) => stdout += chunk.toString());
|
||||||
|
|
||||||
child.once('close', function(code) {
|
child.once('close', (code) => {
|
||||||
const elapsed = process.hrtime(benchmarker_start);
|
const elapsed = process.hrtime(benchmarker_start);
|
||||||
if (code) {
|
if (code) {
|
||||||
let error_message = `${options.benchmarker} failed with ${code}.`;
|
let error_message = `${options.benchmarker} failed with ${code}.`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user