Skip to content

Commit 841abf4

Browse files
ian-perkinsMylesBorins
authored andcommitted
benchmark: fix issues in dns benchmark
The benchmark script for dns contained functions with args declared but never used. This fix removes those arguments from the function signatures. No test existed for the dns benchmark so one was added to the parallel suite. To improve performance the tests are limited to 1 invocation to a single endpoint. PR-URL: #14936 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent 2dbaa74 commit 841abf4

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

benchmark/dns/lookup.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ const lookup = require('dns').lookup;
55

66
const bench = common.createBenchmark(main, {
77
name: ['', '127.0.0.1', '::1'],
8-
all: [true, false],
8+
all: ['true', 'false'],
99
n: [5e6]
1010
});
1111

1212
function main(conf) {
1313
const name = conf.name;
1414
const n = +conf.n;
15-
const all = !!conf.all;
15+
const all = conf.all === 'true' ? true : false;
1616
var i = 0;
1717

1818
if (all) {
1919
const opts = { all: true };
2020
bench.start();
21-
(function cb(err, results) {
21+
(function cb() {
2222
if (i++ === n) {
2323
bench.end(n);
2424
return;
@@ -27,7 +27,7 @@ function main(conf) {
2727
})();
2828
} else {
2929
bench.start();
30-
(function cb(err, result) {
30+
(function cb() {
3131
if (i++ === n) {
3232
bench.end(n);
3333
return;

test/parallel/test-benchmark-dns.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
require('../common');
4+
5+
// Minimal test for dns benchmarks. This makes sure the benchmarks aren't
6+
// horribly broken but nothing more than that.
7+
8+
const assert = require('assert');
9+
const fork = require('child_process').fork;
10+
const path = require('path');
11+
12+
const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js');
13+
14+
const env = Object.assign({}, process.env,
15+
{ NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
16+
17+
const child = fork(runjs,
18+
['--set', 'n=1',
19+
'--set', 'all=false',
20+
'--set', 'name=127.0.0.1',
21+
'dns'],
22+
{ env });
23+
24+
child.on('exit', (code, signal) => {
25+
assert.strictEqual(code, 0);
26+
assert.strictEqual(signal, null);
27+
});

0 commit comments

Comments
 (0)