| 1 | """Benchmarks.""" |
| 2 | |
| 3 | import pathlib |
| 4 | |
| 5 | from pytest_codspeed import BenchmarkFixture |
| 6 | |
| 7 | from annotatedyaml import parse_yaml |
| 8 | |
| 9 | FIXTURE_PATH = pathlib.Path(__file__).parent.parent.joinpath("fixtures") |
| 10 | |
| 11 | |
| 12 | def test_simple_parse_yaml(benchmark: BenchmarkFixture) -> None: |
| 13 | """Test parsing a simple YAML file.""" |
| 14 | yaml_str = FIXTURE_PATH.joinpath("simple_automations.yaml").read_text() |
| 15 | |
| 16 | @benchmark |
| 17 | def _parse_yaml() -> None: |
| 18 | parse_yaml(yaml_str) |
| 19 | |
| 20 | |
| 21 | def test_large_parse_yaml(benchmark: BenchmarkFixture) -> None: |
| 22 | """Test parsing a large YAML file.""" |
| 23 | yaml_str = FIXTURE_PATH.joinpath("large_automations.yaml").read_text() |
| 24 | |
| 25 | @benchmark |
| 26 | def _parse_yaml() -> None: |
| 27 | parse_yaml(yaml_str) |