Skip to content

Commit

Permalink
Add missing benchmark for less common operations (#1323)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Oct 18, 2024
1 parent fcb8d7c commit 6601ba5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_url_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 6601ba5

Please sign in to comment.