benchmark: fix dgram/bind-params.js benchmark · nodejs/node@a8b917e

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

}