Skip to content

Commit

Permalink
Add benchmarks for calling origin() on a URL with credentials (#1278)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Oct 15, 2024
1 parent a9ba9bb commit 84677e9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_url_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
MANY_HOSTS = [f"www.domain{i}.tld" for i in range(256)]
MANY_URLS = [f"https://www.domain{i}.tld" for i in range(256)]
BASE_URL = URL("http://www.domain.tld")
URL_WITH_USER_PASS = URL("http://user:password@www.domain.tld")
IPV6_QUERY_URL = URL("http://[::1]/req?query=1&query=2&query=3&query=4&query=5")
URL_WITH_NOT_DEFAULT_PORT = URL("http://www.domain.tld:1234")
QUERY_URL = URL("http://www.domain.tld?query=1&query=2&query=3&query=4&query=5")
Expand Down Expand Up @@ -309,6 +310,13 @@ def _run() -> None:
BASE_URL.origin()


def test_url_origin_with_user_pass(benchmark: BenchmarkFixture) -> None:
@benchmark
def _run() -> None:
for _ in range(100):
URL_WITH_USER_PASS.origin()


def test_url_with_path_origin(benchmark: BenchmarkFixture) -> None:
@benchmark
def _run() -> None:
Expand Down

0 comments on commit 84677e9

Please sign in to comment.