Skip to content

Commit 48db583

Browse files
committed
modified the benchmark test
1 parent 66dd3f6 commit 48db583

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

benchmark/streams/finished.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
'use strict';
22

33
const common = require('../common');
4-
const { Readable, Writable, Duplex, finished } = require('stream');
4+
const { Readable, Writable } = require('stream');
5+
const { finished } = require('stream/promises');
56

67
const bench = common.createBenchmark(main, {
78
n: [1e5],
8-
streamType: ['readable', 'writable', 'duplex'],
9+
streamType: ['readable', 'writable'],
910
});
1011

11-
function main({ n, streamType }) {
12+
async function main({ n, streamType }) {
1213
bench.start();
1314

1415
for (let i = 0; i < n; i++) {
@@ -17,21 +18,15 @@ function main({ n, streamType }) {
1718
switch (streamType) {
1819
case 'readable':
1920
stream = new Readable({ read() { this.push(null); } });
21+
stream.resume();
2022
break;
2123
case 'writable':
2224
stream = new Writable({ write(chunk, enc, cb) { cb(); } });
2325
stream.end();
2426
break;
25-
case 'duplex':
26-
stream = new Duplex({
27-
read() { this.push(null); },
28-
write(chunk, enc, cb) { cb(); },
29-
});
30-
stream.end();
31-
break;
3227
}
3328

34-
finished(stream, () => {});
29+
await finished(stream);
3530
}
3631

3732
bench.end(n);

0 commit comments

Comments
 (0)