Skip to content

Commit

Permalink
Pass HTTPS stack through PGO collection
Browse files Browse the repository at this point in the history
  • Loading branch information
dvolodin7 committed Mar 12, 2024
1 parent f313d1f commit fe5f8ff
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions tools/build/pgo-runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import random

# Gufo HTTP modules
from gufo.http.httpd import Httpd
from gufo.http.httpd import Httpd, HttpdMode
from gufo.http.sync_client import HttpClient as SyncHttpClient
from gufo.http.async_client import HttpClient as AsyncHttpClient

Expand All @@ -20,6 +20,7 @@
HTTPD_HOST = "local.gufolabs.com"
HTTPD_ADDRESS = "127.0.0.1"
HTTPD_PORT = random.randint(52000, 53999)
HTTPD_SSL_PORT = random.randint(52000, 53999)
REPEATS = 100


Expand All @@ -32,7 +33,7 @@ def run_single_sync(prefix: str) -> None:
"""
url = f"{prefix}/bench-1k.txt"
for _ in range(REPEATS):
with SyncHttpClient() as client:
with SyncHttpClient(validate_cert=False) as client:
resp = client.get(url)
resp.read()

Expand All @@ -46,7 +47,7 @@ async def run_single_async(prefix: str) -> None:
"""
url = f"{prefix}/bench-1k.txt"
for _ in range(REPEATS):
async with AsyncHttpClient() as client:
async with AsyncHttpClient(validate_cert=False) as client:
resp = await client.get(url)
await resp.read()

Expand All @@ -59,7 +60,7 @@ def run_linear_sync(prefix: str) -> None:
prefix: URL prefix
"""
url = f"{prefix}/bench-1k.txt"
with SyncHttpClient() as client:
with SyncHttpClient(validate_cert=False) as client:
for _ in range(REPEATS):
resp = client.get(url)
resp.read()
Expand All @@ -73,7 +74,7 @@ async def run_linear_async(prefix: str) -> None:
prefix: URL prefix
"""
url = f"{prefix}/bench-1k.txt"
async with AsyncHttpClient() as client:
async with AsyncHttpClient(validate_cert=False) as client:
for _ in range(REPEATS):
resp = await client.get(url)
await resp.read()
Expand All @@ -89,11 +90,26 @@ def main() -> None:
host=HTTPD_HOST,
)
httpd._start()
# Create HTTPS istance
httpd_ssl = Httpd(
path=HTTPD_PATH,
address=HTTPD_ADDRESS,
port=HTTPD_SSL_PORT,
host=HTTPD_HOST,
mode=HttpdMode.HTTPS,
)
httpd_ssl._start()
# Run tests
# HTTP
run_single_sync(httpd.prefix)
asyncio.run(run_single_async(httpd.prefix))
run_linear_sync(httpd.prefix)
asyncio.run(run_linear_async(httpd.prefix))
# SSL
run_single_sync(httpd_ssl.prefix)
asyncio.run(run_single_async(httpd_ssl.prefix))
run_linear_sync(httpd_ssl.prefix)
asyncio.run(run_linear_async(httpd_ssl.prefix))


if __name__ == "__main__":
Expand Down

0 comments on commit fe5f8ff

Please sign in to comment.