Skip to content

Commit

Permalink
fixup: test w/ callback
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Dec 23, 2019
1 parent d1603cd commit 4155712
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions benchmark/streams/writable-manywrites.js
Expand Up @@ -6,10 +6,13 @@ const Writable = require('stream').Writable;
const bench = common.createBenchmark(main, {
n: [2e6],
sync: ['yes', 'no'],
writev: ['yes', 'no']
writev: ['yes', 'no'],
callback: ['yes', 'no']
});

function main({ n, sync, writev }) {
function nop() {}

function main({ n, sync, writev, callback }) {
const b = Buffer.allocUnsafe(1024);
const s = new Writable();
sync = sync === 'yes';
Expand All @@ -30,11 +33,13 @@ function main({ n, sync, writev }) {
};
}

const cb = callback === 'yes' ? nop : null;

bench.start();

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

0 comments on commit 4155712

Please sign in to comment.