mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
benchmark: update num to n in dgram offset-length
PR-URL: https://github.com/nodejs/node/pull/59872 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
committed by
Node.js GitHub Bot
parent
4dc19ec9ac
commit
1e008dab21
@@ -10,23 +10,23 @@ const PORT = common.PORT;
|
|||||||
// event loop cycles more than anything else.
|
// event loop cycles more than anything else.
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
len: [1, 64, 256, 1024],
|
len: [1, 64, 256, 1024],
|
||||||
num: [100],
|
n: [100],
|
||||||
type: ['send', 'recv'],
|
type: ['send', 'recv'],
|
||||||
dur: [5],
|
dur: [5],
|
||||||
});
|
});
|
||||||
|
|
||||||
function main({ dur, len, num, type }) {
|
function main({ dur, len, num: n, type }) {
|
||||||
const chunk = Buffer.allocUnsafe(len);
|
const chunk = Buffer.allocUnsafe(len);
|
||||||
let sent = 0;
|
let sent = 0;
|
||||||
let received = 0;
|
let received = 0;
|
||||||
const socket = dgram.createSocket('udp4');
|
const socket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
function onsend() {
|
function onsend() {
|
||||||
if (sent++ % num === 0) {
|
if (sent++ % n === 0) {
|
||||||
// The setImmediate() is necessary to have event loop progress on OSes
|
// The setImmediate() is necessary to have event loop progress on OSes
|
||||||
// that only perform synchronous I/O on nonblocking UDP sockets.
|
// that only perform synchronous I/O on nonblocking UDP sockets.
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
for (let i = 0; i < num; i++) {
|
for (let i = 0; i < n; i++) {
|
||||||
socket.send(chunk, PORT, '127.0.0.1', onsend);
|
socket.send(chunk, PORT, '127.0.0.1', onsend);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user