2017-05-27 20:35:13 -04:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common.js');
|
|
|
|
const lookup = require('dns').lookup;
|
|
|
|
|
|
|
|
const bench = common.createBenchmark(main, {
|
2019-04-04 10:49:29 -07:00
|
|
|
name: ['127.0.0.1', '::1'],
|
2017-08-18 12:09:57 +01:00
|
|
|
all: ['true', 'false'],
|
2023-01-29 20:13:35 +02:00
|
|
|
n: [5e6],
|
2017-05-27 20:35:13 -04:00
|
|
|
});
|
|
|
|
|
2017-12-30 04:01:23 +01:00
|
|
|
function main({ name, n, all }) {
|
2020-02-14 13:02:27 +01:00
|
|
|
let i = 0;
|
2017-05-27 20:35:13 -04:00
|
|
|
|
2017-12-30 04:01:23 +01:00
|
|
|
if (all === 'true') {
|
2017-05-27 20:35:13 -04:00
|
|
|
const opts = { all: true };
|
|
|
|
bench.start();
|
2017-08-18 12:09:57 +01:00
|
|
|
(function cb() {
|
2017-05-27 20:35:13 -04:00
|
|
|
if (i++ === n) {
|
|
|
|
bench.end(n);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
lookup(name, opts, cb);
|
|
|
|
})();
|
|
|
|
} else {
|
|
|
|
bench.start();
|
2017-08-18 12:09:57 +01:00
|
|
|
(function cb() {
|
2017-05-27 20:35:13 -04:00
|
|
|
if (i++ === n) {
|
|
|
|
bench.end(n);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
lookup(name, cb);
|
|
|
|
})();
|
|
|
|
}
|
|
|
|
}
|