Skip to content

Commit

Permalink
Add network backend benchmark param
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusSintonen committed Jun 18, 2024
1 parent b47b4c2 commit 3814cf4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/benchmark/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
import os
import sys
import time
from concurrent.futures import ThreadPoolExecutor
Expand All @@ -21,7 +20,7 @@
CONCURRENCY = 20
POOL_LIMIT = 100
PROFILE = False
os.environ["HTTPCORE_PREFER_ANYIO"] = "0"
NET_BACKEND = httpcore.AsyncioBackend


def duration(start: float) -> int:
Expand Down Expand Up @@ -66,7 +65,9 @@ async def aiohttp_get(session: aiohttp.ClientSession, timings: List[int]) -> Non
assert res.status == 200, f"status={res.status}"
timings.append(duration(start))

async with httpcore.AsyncConnectionPool(max_connections=POOL_LIMIT) as pool:
async with httpcore.AsyncConnectionPool(
max_connections=POOL_LIMIT, network_backend=NET_BACKEND()
) as pool:
# warmup
await gather_limited_concurrency(
(httpcore_get(pool, []) for _ in range(REQUESTS)), CONCURRENCY * 2
Expand Down

0 comments on commit 3814cf4

Please sign in to comment.