mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 21:35:34 +00:00

The benchmarks for dns.lookup() include calling it with an empty hostname which results in a deprecation warning. This benchmark seems to be subject to some odd side effects (see Ref below) and we probably generally don't want to benchmark deprecated things by default anyway. Remove the deprecated value from the default list. Bonus is that this will speed up the benchmark. Refs: https://github.com/nodejs/node/pull/27081#issuecomment-479981874 PR-URL: https://github.com/nodejs/node/pull/27091 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
36 lines
624 B
JavaScript
36 lines
624 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common.js');
|
|
const lookup = require('dns').lookup;
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
name: ['127.0.0.1', '::1'],
|
|
all: ['true', 'false'],
|
|
n: [5e6]
|
|
});
|
|
|
|
function main({ name, n, all }) {
|
|
var i = 0;
|
|
|
|
if (all === 'true') {
|
|
const opts = { all: true };
|
|
bench.start();
|
|
(function cb() {
|
|
if (i++ === n) {
|
|
bench.end(n);
|
|
return;
|
|
}
|
|
lookup(name, opts, cb);
|
|
})();
|
|
} else {
|
|
bench.start();
|
|
(function cb() {
|
|
if (i++ === n) {
|
|
bench.end(n);
|
|
return;
|
|
}
|
|
lookup(name, cb);
|
|
})();
|
|
}
|
|
}
|