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

Let's add superagent to the benchmark. closes #2730 #2731

Merged
merged 2 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions benchmarks/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { Pool, Client, fetch, Agent, setGlobalDispatcher } = require('..')

let nodeFetch
const axios = require('axios')
let superagent
let got

const util = require('node:util')
Expand Down Expand Up @@ -85,6 +86,11 @@ const requestAgent = new http.Agent({
maxSockets: connections
})

const superagentAgent = new http.Agent({
keepAlive: true,
maxSockets: connections
})

const undiciOptions = {
path: '/',
method: 'GET',
Expand Down Expand Up @@ -318,6 +324,16 @@ if (process.env.PORT) {
}).catch(console.log)
})
}

experiments.superagent = () => {
return makeParallelRequests(resolve => {
superagent.get(dest.url).pipe(new Writable({
eddienubes marked this conversation as resolved.
Show resolved Hide resolved
write (chunk, encoding, callback) {
callback()
}
})).on('finish', resolve)
})
}
}

async function main () {
Expand All @@ -326,6 +342,9 @@ async function main () {
nodeFetch = _nodeFetch.default
const _got = await import('got')
got = _got.default
const _superagent = await import('superagent')
// https://github.com/ladjs/superagent/issues/1540#issue-561464561
superagent = _superagent.agent().use((req) => req.agent(superagentAgent))

cronometro(
experiments,
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"@matteo.collina/tspl": "^0.1.1",
"@sinonjs/fake-timers": "^11.1.0",
"@types/node": "^18.0.3",
"@types/superagent": "^8.1.3",
"abort-controller": "^3.0.0",
"axios": "^1.6.5",
"borp": "^0.9.1",
Expand All @@ -128,6 +129,7 @@
"sinon": "^17.0.1",
"snazzy": "^9.0.0",
"standard": "^17.0.0",
"superagent": "^8.1.2",
"tap": "^16.1.0",
"tsd": "^0.30.1",
"typescript": "^5.0.2",
Expand Down
Loading