From 6601ba5038fe24d09e23dbc3959f254bd3ea5cc3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 17 Oct 2024 14:46:14 -1000 Subject: [PATCH] Add missing benchmark for less common operations (#1323) --- tests/test_url_benchmarks.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_url_benchmarks.py b/tests/test_url_benchmarks.py index 92df03d92..edbf48e7e 100644 --- a/tests/test_url_benchmarks.py +++ b/tests/test_url_benchmarks.py @@ -398,6 +398,13 @@ def _run() -> None: BASE_URL.with_scheme("https") +def test_url_with_name(benchmark: BenchmarkFixture) -> None: + @benchmark + def _run() -> None: + for _ in range(100): + BASE_URL.with_name("other.tld") + + def test_url_with_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -439,6 +446,16 @@ def _run() -> None: URL_WITH_PATH.relative() +def test_url_with_path_parent(benchmark: BenchmarkFixture) -> None: + cache = URL_WITH_PATH._cache + + @benchmark + def _run() -> None: + for _ in range(100): + cache.pop("parent", None) + URL_WITH_PATH.parent + + def test_url_join(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -469,6 +486,16 @@ def _run() -> None: URL_WITH_PATH == URL_WITH_PATH +def test_url_hash(benchmark: BenchmarkFixture) -> None: + cache = BASE_URL._cache + + @benchmark + def _run() -> None: + for _ in range(100): + cache.pop("hash", None) + hash(BASE_URL) + + def test_is_default_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: