Skip to content

Commit

Permalink
benchmark: use Writable instead of Passthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Jun 26, 2020
1 parent bc8a13f commit 28c5e97
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions benchmarks/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'
const { PassThrough } = require('stream')
const { Writable } = require('stream')
const http = require('http')
const Benchmark = require('benchmark')
const undici = require('..')
Expand Down Expand Up @@ -44,7 +44,11 @@ suite
defer: true,
fn: deferred => {
http.get(httpOptions, response => {
const stream = new PassThrough()
const stream = new Writable({
write (chunk, encoding, callback) {
callback()
}
})
stream.once('finish', () => {
deferred.resolve()
})
Expand All @@ -61,7 +65,11 @@ suite
throw error
}

const stream = new PassThrough()
const stream = new Writable({
write (chunk, encoding, callback) {
callback()
}
})
stream.once('finish', () => {
deferred.resolve()
})
Expand All @@ -81,7 +89,11 @@ suite
throw err
})
.end()
.pipe(new PassThrough())
.pipe(new Writable({
write (chunk, encoding, callback) {
callback()
}
}))
.on('error', (err) => {
throw err
})
Expand All @@ -94,7 +106,11 @@ suite
defer: true,
fn: deferred => {
pool.stream(undiciOptions, () => {
const stream = new PassThrough()
const stream = new Writable({
write (chunk, encoding, callback) {
callback()
}
})
stream.once('finish', () => {
deferred.resolve()
})
Expand Down

0 comments on commit 28c5e97

Please sign in to comment.