1'use strict'; 2 3const common = require('../common.js'); 4const lookup = require('dns').lookup; 5 6const bench = common.createBenchmark(main, { 7 name: ['127.0.0.1', '::1'], 8 all: ['true', 'false'], 9 n: [5e6], 10}); 11 12function main({ name, n, all }) { 13 let i = 0; 14 15 if (all === 'true') { 16 const opts = { all: true }; 17 bench.start(); 18 (function cb() { 19 if (i++ === n) { 20 bench.end(n); 21 return; 22 } 23 lookup(name, opts, cb); 24 })(); 25 } else { 26 bench.start(); 27 (function cb() { 28 if (i++ === n) { 29 bench.end(n); 30 return; 31 } 32 lookup(name, cb); 33 })(); 34 } 35} 36