Skip to content

Commit 978889f

Browse files
TrottMylesBorins
authored andcommitted
benchmark: fix dgram/bind-params.js benchmark
`benchmark/dgram/bind-params` exits with an error frequently in its current form because no error handler is applied. Add no-op error handlers to avoid the problem. ```console $ node benchmark/run.js --filter bind-params dgram dgram/bind-params.js dgram/bind-params.js address="true" port="true" n=10000: 193,347.42178656923 events.js:182 throw er; // Unhandled 'error' event ^ Error: bind ENFILE 0.0.0.0 at Object._errnoException (util.js:1041:11) at _exceptionWithHostPort (util.js:1064:20) at _handle.lookup (dgram.js:242:18) at _combinedTickCallback (internal/process/next_tick.js:141:11) at process._tickCallback (internal/process/next_tick.js:180:9) at Function.Module.runMain (module.js:611:11) at startup (bootstrap_node.js:158:16) at bootstrap_node.js:598:3 $ ``` PR-URL: #14948 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent c8be90c commit 978889f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

benchmark/dgram/bind-params.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const configs = {
1010
};
1111

1212
const bench = common.createBenchmark(main, configs);
13+
const noop = () => {};
1314

1415
function main(conf) {
1516
const n = +conf.n;
@@ -19,19 +20,27 @@ function main(conf) {
1920
if (port !== undefined && address !== undefined) {
2021
bench.start();
2122
for (let i = 0; i < n; i++) {
22-
dgram.createSocket('udp4').bind(port, address).unref();
23+
dgram.createSocket('udp4').bind(port, address)
24+
.on('error', noop)
25+
.unref();
2326
}
2427
bench.end(n);
2528
} else if (port !== undefined) {
2629
bench.start();
2730
for (let i = 0; i < n; i++) {
28-
dgram.createSocket('udp4').bind(port).unref();
31+
dgram.createSocket('udp4')
32+
.bind(port)
33+
.on('error', noop)
34+
.unref();
2935
}
3036
bench.end(n);
3137
} else if (port === undefined && address === undefined) {
3238
bench.start();
3339
for (let i = 0; i < n; i++) {
34-
dgram.createSocket('udp4').bind().unref();
40+
dgram.createSocket('udp4')
41+
.bind()
42+
.on('error', noop)
43+
.unref();
3544
}
3645
bench.end(n);
3746
}

0 commit comments

Comments
 (0)