Skip to content

Commit 18b344c

Browse files
Trottaddaleax
authored andcommitted
benchmark: refactor benchmark/common.js
Refactor benchmark/common.js to consistently use arrow functions for anonymous callbacks and trailing commas. PR-URL: #25805 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 40398fd commit 18b344c

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

benchmark/common.js

+18-17
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,19 @@ Benchmark.prototype.http = function(options, cb) {
118118
self.config.benchmarker ||
119119
self.extra_options.benchmarker ||
120120
exports.default_http_benchmarker;
121-
http_benchmarkers.run(http_options, function(error, code, used_benchmarker,
122-
result, elapsed) {
123-
if (cb) {
124-
cb(code);
125-
}
126-
if (error) {
127-
console.error(error);
128-
process.exit(code || 1);
121+
http_benchmarkers.run(
122+
http_options, (error, code, used_benchmarker, result, elapsed) => {
123+
if (cb) {
124+
cb(code);
125+
}
126+
if (error) {
127+
console.error(error);
128+
process.exit(code || 1);
129+
}
130+
self.config.benchmarker = used_benchmarker;
131+
self.report(result, elapsed);
129132
}
130-
self.config.benchmarker = used_benchmarker;
131-
self.report(result, elapsed);
132-
});
133+
);
133134
};
134135

135136
Benchmark.prototype._run = function() {
@@ -139,7 +140,7 @@ Benchmark.prototype._run = function() {
139140
process.send({
140141
type: 'config',
141142
name: this.name,
142-
queueLength: this.queue.length
143+
queueLength: this.queue.length,
143144
});
144145
}
145146

@@ -162,10 +163,10 @@ Benchmark.prototype._run = function() {
162163

163164
const child = child_process.fork(require.main.filename, childArgs, {
164165
env: childEnv,
165-
execArgv: self.flags.concat(process.execArgv)
166+
execArgv: self.flags.concat(process.execArgv),
166167
});
167168
child.on('message', sendResult);
168-
child.on('close', function(code) {
169+
child.on('close', (code) => {
169170
if (code) {
170171
process.exit(code);
171172
return;
@@ -241,7 +242,7 @@ Benchmark.prototype.report = function(rate, elapsed) {
241242
conf: this.config,
242243
rate: rate,
243244
time: elapsed[0] + elapsed[1] / 1e9,
244-
type: 'report'
245+
type: 'report',
245246
});
246247
};
247248

@@ -267,7 +268,7 @@ const urls = {
267268
ws: 'ws://localhost:9229/f46db715-70df-43ad-a359-7f9949f39868',
268269
javascript: 'javascript:alert("node is awesome");',
269270
percent: 'https://%E4%BD%A0/foo',
270-
dot: 'https://example.org/./a/../b/./c'
271+
dot: 'https://example.org/./a/../b/./c',
271272
};
272273
exports.urls = urls;
273274

@@ -282,7 +283,7 @@ const searchParams = {
282283
'foo=ghi&foo=jkl&foo=mno&foo=pqr&foo=stu&foo=vwxyz',
283284
manypairs: 'a&b&c&d&e&f&g&h&i&j&k&l&m&n&o&p&q&r&s&t&u&v&w&x&y&z',
284285
manyblankpairs: '&&&&&&&&&&&&&&&&&&&&&&&&',
285-
altspaces: 'foo+bar=baz+quux&xyzzy+thud=quuy+quuz&abc=def+ghi'
286+
altspaces: 'foo+bar=baz+quux&xyzzy+thud=quuy+quuz&abc=def+ghi',
286287
};
287288
exports.searchParams = searchParams;
288289

0 commit comments

Comments
 (0)