Skip to content

Commit

Permalink
Add benchmark for calling update_query with a query string (#1329)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Oct 18, 2024
1 parent a071e6d commit 1350a41
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_url_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
QUERY_SEQ = {str(i): tuple(str(j) for j in range(10)) for i in range(10)}
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"


class _SubClassedStr(str):
Expand Down Expand Up @@ -312,6 +313,13 @@ def _run() -> None:
BASE_URL.update_query(None)


def test_update_query_string(benchmark: BenchmarkFixture) -> None:
@benchmark
def _run() -> None:
for _ in range(25):
BASE_URL.update_query(QUERY_STRING)


def test_url_extend_query_simple_query_dict(benchmark: BenchmarkFixture) -> None:
@benchmark
def _run() -> None:
Expand All @@ -332,7 +340,7 @@ def test_url_extend_query_existing_query_string(benchmark: BenchmarkFixture) ->
@benchmark
def _run() -> None:
for _ in range(25):
QUERY_URL.extend_query("x=y&z=1")
QUERY_URL.extend_query(QUERY_STRING)


def test_url_to_string(benchmark: BenchmarkFixture) -> None:
Expand Down

0 comments on commit 1350a41

Please sign in to comment.