Skip to content

Commit 7a272d2

Browse files
authored
Add benchmark for subtracting long URL paths (#1387)
The performance is currently nearly quadratic so its good to compare a short and long url
1 parent cb550b7 commit 7a272d2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/test_url_benchmarks.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
SIMPLE_QUERY = {str(i): str(i) for i in range(10)}
2525
SIMPLE_INT_QUERY = {str(i): i for i in range(10)}
2626
QUERY_STRING = "x=y&z=1"
27+
URL_VERY_LONG_PATH = URL("http://www.domain.tld/" + "req/" * 100)
28+
URL_LONG_PATH = URL("http://www.domain.tld/" + "req/" * 30)
2729

2830

2931
class _SubClassedStr(str):
@@ -594,6 +596,13 @@ def _run() -> None:
594596
URL_WITH_LONGER_PATH - URL_WITH_PATH
595597

596598

599+
def test_url_subtract_long_urls(benchmark: BenchmarkFixture) -> None:
600+
@benchmark
601+
def _run() -> None:
602+
for _ in range(100):
603+
URL_VERY_LONG_PATH - URL_LONG_PATH
604+
605+
597606
def test_url_host_port_subcomponent(benchmark: BenchmarkFixture) -> None:
598607
cache_non_default = URL_WITH_NOT_DEFAULT_PORT._cache
599608
cache = BASE_URL._cache

0 commit comments

Comments
 (0)