aboutsummaryrefslogtreecommitdiff
path: root/tests/bench/compile.py
blob: 112e05f6eecb50dd638ed8afad27fb82777b2a46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Benchmark: compile-path wall clock across the simple/medium/complex cases."""

from __future__ import annotations

import pytest
from pytest_benchmark.fixture import BenchmarkFixture

from tests.bench.cases import BUILDER_FACTORIES


@pytest.mark.parametrize("case_name", list(BUILDER_FACTORIES))
def test_compile_bench(case_name: str, benchmark: BenchmarkFixture):
    factory = BUILDER_FACTORIES[case_name]
    benchmark(lambda: factory().to_regex())


@pytest.mark.parametrize("case_name", list(BUILDER_FACTORIES))
def test_to_regex_string_bench(case_name: str, benchmark: BenchmarkFixture):
    factory = BUILDER_FACTORIES[case_name]
    benchmark(lambda: factory().to_regex_string())