Skip to content

Commit 0173823

Browse files
committed
keep packets unsent to have data in getters
1 parent b8f08d4 commit 0173823

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

benchmark/dgram/get-send-queue-info.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
const common = require('../common.js');
44
const dgram = require('dgram');
5+
const assert = require('assert');
56

67
const bench = common.createBenchmark(main, {
78
n: [5e6],
89
method: ['size', 'count'],
10+
}, {
11+
flags: ['--test-udp-no-try-send'],
912
});
1013

1114
function main({ n, method }) {
@@ -14,20 +17,27 @@ function main({ n, method }) {
1417

1518
server.bind(0, () => {
1619
client.connect(server.address().port, () => {
20+
// warm-up: keep packets unsent using --test-udp-no-try-send flag
1721
for (let i = 0; i < 999; i++) client.send('Hello');
1822

23+
let size = 0;
24+
let count = 0;
25+
1926
bench.start();
2027

2128
if (method === 'size') {
22-
for (let i = 0; i < n; ++i) server.getSendQueueSize();
29+
for (let i = 0; i < n; ++i) size += client.getSendQueueSize();
2330
} else {
24-
for (let i = 0; i < n; ++i) server.getSendQueueCount();
31+
for (let i = 0; i < n; ++i) count += client.getSendQueueCount();
2532
}
2633

2734
bench.end(n);
2835

2936
client.close();
3037
server.close();
38+
39+
assert.ok(size > 0);
40+
assert.ok(count > 0);
3141
});
3242
});
3343
}

0 commit comments

Comments
 (0)