benchmark: (dgram) use destructuring
PR-URL: https://github.com/nodejs/node/pull/18250 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
d49580d812
commit
b2966043c9
@ -2,6 +2,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
const dgram = require('dgram');
|
||||||
const PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
// `num` is the number of send requests to queue up each time.
|
// `num` is the number of send requests to queue up each time.
|
||||||
@ -15,34 +16,15 @@ const bench = common.createBenchmark(main, {
|
|||||||
dur: [5]
|
dur: [5]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dur;
|
function main({ dur, len, num, type, chunks }) {
|
||||||
var len;
|
const chunk = [];
|
||||||
var num;
|
|
||||||
var type;
|
|
||||||
var chunk;
|
|
||||||
var chunks;
|
|
||||||
|
|
||||||
function main(conf) {
|
|
||||||
dur = +conf.dur;
|
|
||||||
len = +conf.len;
|
|
||||||
num = +conf.num;
|
|
||||||
type = conf.type;
|
|
||||||
chunks = +conf.chunks;
|
|
||||||
|
|
||||||
chunk = [];
|
|
||||||
for (var i = 0; i < chunks; i++) {
|
for (var i = 0; i < chunks; i++) {
|
||||||
chunk.push(Buffer.allocUnsafe(Math.round(len / chunks)));
|
chunk.push(Buffer.allocUnsafe(Math.round(len / chunks)));
|
||||||
}
|
}
|
||||||
|
|
||||||
server();
|
// Server
|
||||||
}
|
|
||||||
|
|
||||||
const dgram = require('dgram');
|
|
||||||
|
|
||||||
function server() {
|
|
||||||
var sent = 0;
|
var sent = 0;
|
||||||
const socket = dgram.createSocket('udp4');
|
const socket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
const onsend = type === 'concat' ? onsendConcat : onsendMulti;
|
const onsend = type === 'concat' ? onsendConcat : onsendMulti;
|
||||||
|
|
||||||
function onsendConcat() {
|
function onsendConcat() {
|
||||||
|
@ -12,10 +12,9 @@ const configs = {
|
|||||||
const bench = common.createBenchmark(main, configs);
|
const bench = common.createBenchmark(main, configs);
|
||||||
const noop = () => {};
|
const noop = () => {};
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, port, address }) {
|
||||||
const n = +conf.n;
|
port = port === 'true' ? 0 : undefined;
|
||||||
const port = conf.port === 'true' ? 0 : undefined;
|
address = address === 'true' ? '0.0.0.0' : undefined;
|
||||||
const address = conf.address === 'true' ? '0.0.0.0' : undefined;
|
|
||||||
|
|
||||||
if (port !== undefined && address !== undefined) {
|
if (port !== undefined && address !== undefined) {
|
||||||
bench.start();
|
bench.start();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
const dgram = require('dgram');
|
||||||
const PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
// `num` is the number of send requests to queue up each time.
|
// `num` is the number of send requests to queue up each time.
|
||||||
@ -15,31 +16,11 @@ const bench = common.createBenchmark(main, {
|
|||||||
dur: [5]
|
dur: [5]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dur;
|
function main({ dur, len, num, type, chunks }) {
|
||||||
var len;
|
const chunk = [];
|
||||||
var num;
|
|
||||||
var type;
|
|
||||||
var chunk;
|
|
||||||
var chunks;
|
|
||||||
|
|
||||||
function main(conf) {
|
|
||||||
dur = +conf.dur;
|
|
||||||
len = +conf.len;
|
|
||||||
num = +conf.num;
|
|
||||||
type = conf.type;
|
|
||||||
chunks = +conf.chunks;
|
|
||||||
|
|
||||||
chunk = [];
|
|
||||||
for (var i = 0; i < chunks; i++) {
|
for (var i = 0; i < chunks; i++) {
|
||||||
chunk.push(Buffer.allocUnsafe(Math.round(len / chunks)));
|
chunk.push(Buffer.allocUnsafe(Math.round(len / chunks)));
|
||||||
}
|
}
|
||||||
|
|
||||||
server();
|
|
||||||
}
|
|
||||||
|
|
||||||
const dgram = require('dgram');
|
|
||||||
|
|
||||||
function server() {
|
|
||||||
var sent = 0;
|
var sent = 0;
|
||||||
var received = 0;
|
var received = 0;
|
||||||
const socket = dgram.createSocket('udp4');
|
const socket = dgram.createSocket('udp4');
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
const dgram = require('dgram');
|
||||||
const PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
// `num` is the number of send requests to queue up each time.
|
// `num` is the number of send requests to queue up each time.
|
||||||
@ -14,24 +15,8 @@ const bench = common.createBenchmark(main, {
|
|||||||
dur: [5]
|
dur: [5]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dur;
|
function main({ dur, len, num, type }) {
|
||||||
var len;
|
const chunk = Buffer.allocUnsafe(len);
|
||||||
var num;
|
|
||||||
var type;
|
|
||||||
var chunk;
|
|
||||||
|
|
||||||
function main(conf) {
|
|
||||||
dur = +conf.dur;
|
|
||||||
len = +conf.len;
|
|
||||||
num = +conf.num;
|
|
||||||
type = conf.type;
|
|
||||||
chunk = Buffer.allocUnsafe(len);
|
|
||||||
server();
|
|
||||||
}
|
|
||||||
|
|
||||||
const dgram = require('dgram');
|
|
||||||
|
|
||||||
function server() {
|
|
||||||
var sent = 0;
|
var sent = 0;
|
||||||
var received = 0;
|
var received = 0;
|
||||||
const socket = dgram.createSocket('udp4');
|
const socket = dgram.createSocket('udp4');
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
const dgram = require('dgram');
|
||||||
const PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
// `num` is the number of send requests to queue up each time.
|
// `num` is the number of send requests to queue up each time.
|
||||||
@ -14,24 +15,8 @@ const bench = common.createBenchmark(main, {
|
|||||||
dur: [5]
|
dur: [5]
|
||||||
});
|
});
|
||||||
|
|
||||||
var dur;
|
function main({ dur, len, num, type }) {
|
||||||
var len;
|
const chunk = Buffer.allocUnsafe(len);
|
||||||
var num;
|
|
||||||
var type;
|
|
||||||
var chunk;
|
|
||||||
|
|
||||||
function main(conf) {
|
|
||||||
dur = +conf.dur;
|
|
||||||
len = +conf.len;
|
|
||||||
num = +conf.num;
|
|
||||||
type = conf.type;
|
|
||||||
chunk = Buffer.allocUnsafe(len);
|
|
||||||
server();
|
|
||||||
}
|
|
||||||
|
|
||||||
const dgram = require('dgram');
|
|
||||||
|
|
||||||
function server() {
|
|
||||||
var sent = 0;
|
var sent = 0;
|
||||||
var received = 0;
|
var received = 0;
|
||||||
const socket = dgram.createSocket('udp4');
|
const socket = dgram.createSocket('udp4');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user