This commit is contained in:
Andrew Pimenov 2026-08-26 17:08:23 +03:00 • committed by GitHub
commit 08ee51c322
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -157,13 +157,14 @@ async def tier_cloudflare(client: httpx.AsyncClient, cfg: Speedtest, timeout: fl
response.raise_for_status()
down_samples.append((len(response.content), time.perf_counter() - began))
cfl4 = parse_server_timing_cfl4(response.headers.get("server-timing", "")) or cfl4
up_samples: list[tuple[int, float]] = []
for size in cfg.upload_sizes_bytes:
async def upload_task(size: int) -> tuple[int, float]:
payload = b"\x00" * size
began = time.perf_counter()
response = await client.post(f"{cfg.cloudflare_base_url}/__up", content=payload, timeout=timeout)
response.raise_for_status()
up_samples.append((size, time.perf_counter() - began))
return size, time.perf_counter() - began
up_samples = await asyncio.gather(*(upload_task(size) for size in cfg.upload_sizes_bytes))
return SpeedResult(
method="cloudflare",
download_mbps=throughput_from_samples(down_samples),