Skip to content

Commit

Permalink
benchmark: update manywrites back pressure
Browse files Browse the repository at this point in the history
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 <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
ronag authored and targos committed Jan 14, 2020
1 parent e6907f0 commit 1333798
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions benchmark/streams/writable-manywrites.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ function main({ n, sync }) {
};

bench.start();
for (var k = 0; k < n; ++k) {
s.write(b);

let k = 0;
function run() {
while (k++ < n && s.write(b));
if (k >= n)
bench.end(n);
}
bench.end(n);
s.on('drain', run);
run();
}

0 comments on commit 1333798

Please sign in to comment.