Skip to content
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
6 changes: 3 additions & 3 deletions benchmarks/benchmark-http2.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const { isMainThread } = require('node:worker_threads')

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

const { cronometro } = require('cronometro')

const ca = readFileSync(path.join(__dirname, '..', 'test', 'fixtures', 'ca.pem'), 'utf8')
const servername = 'agent1'

Expand Down Expand Up @@ -258,9 +260,7 @@ if (process.env.PORT) {
}
}

async function main () {
const { cronometro } = await import('cronometro')

function main () {
cronometro(
experiments,
{
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/benchmark-https.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const { isMainThread } = require('node:worker_threads')

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

const { cronometro } = require('cronometro')

const ca = readFileSync(path.join(__dirname, '..', 'test', 'fixtures', 'ca.pem'), 'utf8')
const servername = 'agent1'

Expand Down Expand Up @@ -267,9 +269,7 @@ if (process.env.PORT) {
}
}

async function main () {
const { cronometro } = await import('cronometro')

function main () {
cronometro(
experiments,
{
Expand Down
21 changes: 8 additions & 13 deletions benchmarks/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ const { Pool, Client, fetch, Agent, setGlobalDispatcher } = require('..')

const { makeParallelRequests, printResults } = require('./_util')

let nodeFetch
const { cronometro } = require('cronometro')
const { default: nodeFetch } = require('node-fetch')
const axios = require('axios')
let superagent
let got
const _superagent = require('superagent')
const { default: got } = require('got')

const { promisify } = require('node:util')
const request = promisify(require('request'))
Expand Down Expand Up @@ -86,6 +87,9 @@ const superagentAgent = new http.Agent({
maxSockets: connections
})

// https://github.com/ladjs/superagent/issues/1540#issue-561464561
const superagent = _superagent.agent().use((req) => req.agent(superagentAgent))

const undiciOptions = {
path: '/',
method: 'GET',
Expand Down Expand Up @@ -328,16 +332,7 @@ if (process.env.PORT) {
}
}

async function main () {
const { cronometro } = await import('cronometro')
const _nodeFetch = await import('node-fetch')
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))

function main () {
// cronometro runs each benchmark in a worker, so attach cleanup to every
// test before the worker exits.
const tests = Object.fromEntries(
Expand Down
21 changes: 8 additions & 13 deletions benchmarks/post-benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ const { Pool, Client, fetch, Agent, setGlobalDispatcher } = require('..')

const { makeParallelRequests, printResults } = require('./_util')

let nodeFetch
const { cronometro } = require('cronometro')
const { default: nodeFetch } = require('node-fetch')
const axios = require('axios')
let superagent
let got
const _superagent = require('superagent')
const { default: got } = require('got')

const { promisify } = require('node:util')
const request = promisify(require('request'))
Expand Down Expand Up @@ -95,6 +96,9 @@ const superagentAgent = new http.Agent({
maxSockets: connections
})

// https://github.com/ladjs/superagent/issues/1540#issue-561464561
const superagent = _superagent.agent().use((req) => req.agent(superagentAgent))

/** @type {import("..").Dispatcher.DispatchOptions} */
const undiciOptions = {
path: '/',
Expand Down Expand Up @@ -353,16 +357,7 @@ if (process.env.PORT) {
}
}

async function main () {
const { cronometro } = await import('cronometro')
const _nodeFetch = await import('node-fetch')
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))

function main () {
cronometro(
experiments,
{
Expand Down
Loading