Skip to content

Commit

Permalink
Add benchmark for human_repr (#1273)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Oct 15, 2024
1 parent 598cc0c commit 21b38a2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 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")
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")
URL_WITH_PATH = URL("http://www.domain.tld/req")
Expand Down Expand Up @@ -358,3 +359,15 @@ def _run() -> None:
for _ in range(100):
BASE_URL.is_default_port()
URL_WITH_NOT_DEFAULT_PORT.is_default_port()


def test_human_repr(benchmark: BenchmarkFixture) -> None:
@benchmark
def _run() -> None:
for _ in range(100):
BASE_URL.human_repr()
URL_WITH_PATH.human_repr()
QUERY_URL.human_repr()
URL_WITH_NOT_DEFAULT_PORT.human_repr()
IPV6_QUERY_URL.human_repr()
REL_URL.human_repr()

0 comments on commit 21b38a2

Please sign in to comment.