Skip to content

Commit f98679f

Browse files
committed
benchmark: add benchmark for dns.promises.lookup()
Adding this benchmark will let us check the performance implications of #27081. PR-URL: #27249 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]>
1 parent 2948e96 commit f98679f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

benchmark/dns/lookup-promises.js

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

0 commit comments

Comments
 (0)