0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/dgram/bind-params.js
Anna Henningsen 049709b07d
benchmark: strip BOM in dgram/bind-params
PR-URL: https://github.com/nodejs/node/pull/11479
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-02-24 01:54:45 +01:00

39 lines
946 B
JavaScript

'use strict';
const common = require('../common.js');
const dgram = require('dgram');
const configs = {
n: [1e4],
port: ['true', 'false'],
address: ['true', 'false'],
};
const bench = common.createBenchmark(main, configs);
function main(conf) {
const n = +conf.n;
const port = conf.port === 'true' ? 0 : undefined;
const address = conf.address === 'true' ? '0.0.0.0' : undefined;
if (port !== undefined && address !== undefined) {
bench.start();
for (let i = 0; i < n; i++) {
dgram.createSocket('udp4').bind(port, address).unref();
}
bench.end(n);
} else if (port !== undefined) {
bench.start();
for (let i = 0; i < n; i++) {
dgram.createSocket('udp4').bind(port).unref();
}
bench.end(n);
} else if (port === undefined && address === undefined) {
bench.start();
for (let i = 0; i < n; i++) {
dgram.createSocket('udp4').bind().unref();
}
bench.end(n);
}
}