Skip to content

Commit 3814cf4

Browse files
Add network backend benchmark param
1 parent b47b4c2 commit 3814cf4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/benchmark/client.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import asyncio
2-
import os
32
import sys
43
import time
54
from concurrent.futures import ThreadPoolExecutor
@@ -21,7 +20,7 @@
2120
CONCURRENCY = 20
2221
POOL_LIMIT = 100
2322
PROFILE = False
24-
os.environ["HTTPCORE_PREFER_ANYIO"] = "0"
23+
NET_BACKEND = httpcore.AsyncioBackend
2524

2625

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

69-
async with httpcore.AsyncConnectionPool(max_connections=POOL_LIMIT) as pool:
68+
async with httpcore.AsyncConnectionPool(
69+
max_connections=POOL_LIMIT, network_backend=NET_BACKEND()
70+
) as pool:
7071
# warmup
7172
await gather_limited_concurrency(
7273
(httpcore_get(pool, []) for _ in range(REQUESTS)), CONCURRENCY * 2

0 commit comments

Comments
 (0)