Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
benchmark: update num to n in dgram offset-length
  • Loading branch information
brunocroh committed Sep 12, 2025
commit 0c7f45bd710c9d088655d0c0405724f81277272d
8 changes: 4 additions & 4 deletions benchmark/dgram/single-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ const PORT = common.PORT;
// event loop cycles more than anything else.
const bench = common.createBenchmark(main, {
len: [1, 64, 256, 1024],
num: [100],
n: [100],
type: ['send', 'recv'],
dur: [5],
});

function main({ dur, len, num, type }) {
function main({ dur, len, num: n, type }) {
const chunk = Buffer.allocUnsafe(len);
let sent = 0;
let received = 0;
const socket = dgram.createSocket('udp4');

function onsend() {
if (sent++ % num === 0) {
if (sent++ % n === 0) {
// The setImmediate() is necessary to have event loop progress on OSes
// that only perform synchronous I/O on nonblocking UDP sockets.
setImmediate(() => {
for (let i = 0; i < num; i++) {
for (let i = 0; i < n; i++) {
socket.send(chunk, PORT, '127.0.0.1', onsend);
}
});
Expand Down