mirror of https://github.com/lukechilds/node.git
Browse Source
It appears that either c-ares no longer calls callbacks synchronously or we have since explicitly taken care of the scenarios in which c-ares would call callbacks synchronously (e.g. resolving an IP address or an empty hostname). Therefore we no longer need to have machinery in place to handle possible synchronous callback invocation. This improves performance significantly. PR-URL: https://github.com/nodejs/node/pull/13261 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: James M Snell <jasnell@gmail.com>v6
2 changed files with 44 additions and 43 deletions
@ -0,0 +1,38 @@ |
|||
'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(conf) { |
|||
const name = conf.name; |
|||
const n = +conf.n; |
|||
const all = !!conf.all; |
|||
var i = 0; |
|||
|
|||
if (all) { |
|||
const opts = { all: true }; |
|||
bench.start(); |
|||
(function cb(err, results) { |
|||
if (i++ === n) { |
|||
bench.end(n); |
|||
return; |
|||
} |
|||
lookup(name, opts, cb); |
|||
})(); |
|||
} else { |
|||
bench.start(); |
|||
(function cb(err, result) { |
|||
if (i++ === n) { |
|||
bench.end(n); |
|||
return; |
|||
} |
|||
lookup(name, cb); |
|||
})(); |
|||
} |
|||
} |
Loading…
Reference in new issue