Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1333798

Browse files
ronagtargos
authored andcommittedJan 14, 2020
benchmark: update manywrites back pressure
Make manywrites benchmark a bit more realistic by taking back pressure into account. Otherwise memory usage would no correspond well with real world usage. PR-URL: #30977 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent e6907f0 commit 1333798

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed
 

‎benchmark/streams/writable-manywrites.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ function main({ n, sync }) {
2020
};
2121

2222
bench.start();
23-
for (var k = 0; k < n; ++k) {
24-
s.write(b);
23+
24+
let k = 0;
25+
function run() {
26+
while (k++ < n && s.write(b));
27+
if (k >= n)
28+
bench.end(n);
2529
}
26-
bench.end(n);
30+
s.on('drain', run);
31+
run();
2732
}

0 commit comments

Comments
 (0)
Please sign in to comment.