Skip to content

Commit 3a77692

Browse files
committed
dns: 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. The dns benchmark uses the core dns.lookup() function which does not access the network but instead uses "an operating system facility that can associate names with addresses, and vice versa" e.g. similar to ping; however, it is a synchronous call which runs on the libuv threadpool - the number of test calls was therefore reduced to 5e4 (from 5e6).
1 parent 3cf27f1 commit 3a77692

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

benchmark/dns/lookup.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ 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

@@ -18,7 +18,7 @@ function main(conf) {
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;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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=5e4',
19+
'dns'],
20+
{ env });
21+
22+
child.on('exit', (code, signal) => {
23+
assert.strictEqual(code, 0);
24+
assert.strictEqual(signal, null);
25+
});

0 commit comments

Comments
 (0)