Skip to content

Commit 44d7b92

Browse files
RafaelGSStargos
authored andcommitted
benchmark: calibrate config array-vs-concat
According to nodejs/performance#186 this benchmark was taking 160 secs for a single run. Based on a research in a dedicated machine, the results doesn't have variation based on the configs, so we don't need to bench all variations. Signed-off-by: RafaelGSS <[email protected]> PR-URL: #59587 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent c161635 commit 44d7b92

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

benchmark/dgram/array-vs-concat.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ const common = require('../common.js');
55
const dgram = require('dgram');
66
const PORT = common.PORT;
77

8-
// `num` is the number of send requests to queue up each time.
8+
// `n` is the number of send requests to queue up each time.
99
// Keep it reasonably high (>10) otherwise you're benchmarking the speed of
1010
// event loop cycles more than anything else.
1111
const bench = common.createBenchmark(main, {
12-
len: [64, 256, 512, 1024],
13-
num: [100],
14-
chunks: [1, 2, 4, 8],
12+
len: [64, 512, 1024],
13+
n: [100],
14+
chunks: [1, 4],
1515
type: ['concat', 'multi'],
1616
dur: [5],
1717
});
1818

19-
function main({ dur, len, num, type, chunks }) {
19+
function main({ dur, len, n, type, chunks }) {
2020
const chunk = [];
2121
for (let i = 0; i < chunks; i++) {
2222
chunk.push(Buffer.allocUnsafe(Math.round(len / chunks)));
@@ -28,23 +28,23 @@ function main({ dur, len, num, type, chunks }) {
2828
const onsend = type === 'concat' ? onsendConcat : onsendMulti;
2929

3030
function onsendConcat() {
31-
if (sent++ % num === 0) {
31+
if (sent++ % n === 0) {
3232
// The setImmediate() is necessary to have event loop progress on OSes
3333
// that only perform synchronous I/O on nonblocking UDP sockets.
3434
setImmediate(() => {
35-
for (let i = 0; i < num; i++) {
35+
for (let i = 0; i < n; i++) {
3636
socket.send(Buffer.concat(chunk), PORT, '127.0.0.1', onsend);
3737
}
3838
});
3939
}
4040
}
4141

4242
function onsendMulti() {
43-
if (sent++ % num === 0) {
43+
if (sent++ % n === 0) {
4444
// The setImmediate() is necessary to have event loop progress on OSes
4545
// that only perform synchronous I/O on nonblocking UDP sockets.
4646
setImmediate(() => {
47-
for (let i = 0; i < num; i++) {
47+
for (let i = 0; i < n; i++) {
4848
socket.send(chunk, PORT, '127.0.0.1', onsend);
4949
}
5050
});

0 commit comments

Comments
 (0)