Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(benchmark): set body correctly #2918

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 23 additions & 15 deletions benchmarks/post-benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
const http = require('node:http')
const os = require('node:os')
const path = require('node:path')
const { Writable } = require('node:stream')
const { Writable, Readable, pipeline } = require('node:stream')
const { isMainThread } = require('node:worker_threads')

const { Pool, Client, fetch, Agent, setGlobalDispatcher } = require('..')

let nodeFetch
Expand Down Expand Up @@ -230,19 +229,28 @@ const experiments = {
},
'undici - pipeline' () {
return makeParallelRequests(resolve => {
dispatcher
.pipeline(undiciOptions, data => {
pipeline(
new Readable({
read () {
this.push(data)
this.push(null)
}
}),
dispatcher.pipeline(undiciOptions, data => {
return data.body
})
.end()
.pipe(
new Writable({
write (chunk, encoding, callback) {
callback()
}
})
)
.on('finish', resolve)
}),
new Writable({
write (chunk, encoding, callback) {
callback()
}
}),
(err) => {
if (err != null) {
console.log(err)
}
resolve()
}
)
})
},
'undici - request' () {
Expand Down Expand Up @@ -357,7 +365,7 @@ if (process.env.PORT) {
method: 'POST',
headers,
agent: requestAgent,
data
body: data
}
experiments.request = () => {
return makeParallelRequests(resolve => {
Expand Down