From cd4bc8a89473eb7b580c99e69425ef0986342600 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 24 Oct 2024 12:58:40 -1000 Subject: [PATCH] Add benchmark for subtracting long URL paths The performance is currently nearly quadratic so its good to compare a short and long url --- tests/test_url_benchmarks.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_url_benchmarks.py b/tests/test_url_benchmarks.py index 137db474b..d5737ef4b 100644 --- a/tests/test_url_benchmarks.py +++ b/tests/test_url_benchmarks.py @@ -24,6 +24,8 @@ SIMPLE_QUERY = {str(i): str(i) for i in range(10)} SIMPLE_INT_QUERY = {str(i): i for i in range(10)} QUERY_STRING = "x=y&z=1" +URL_VERY_LONG_PATH = URL("http://www.domain.tld/" + "req/" * 100) +URL_LONG_PATH = URL("http://www.domain.tld/" + "req/" * 30) class _SubClassedStr(str): @@ -594,6 +596,13 @@ def _run() -> None: URL_WITH_LONGER_PATH - URL_WITH_PATH +def test_url_subtract_long_urls(benchmark: BenchmarkFixture) -> None: + @benchmark + def _run() -> None: + for _ in range(100): + URL_VERY_LONG_PATH - URL_LONG_PATH + + def test_url_host_port_subcomponent(benchmark: BenchmarkFixture) -> None: cache_non_default = URL_WITH_NOT_DEFAULT_PORT._cache cache = BASE_URL._cache