Coverage for src/python/ensembl/vep/config/sections/bench/bench.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.17.2, created at 2026-11-18 14:41 +0000

1# See the NOTICE file distributed with this work for additional information 

2# regarding copyright ownership. 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# http://www.apache.org/licenses/LICENSE-2.0 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14"""Options every benchmark verb shares.""" 

15 

16from __future__ import annotations 

17 

18from pathlib import Path 

19from typing import ClassVar 

20 

21from attrs import define, field 

22 

23from ensembl.vep.config.option_spec import option 

24from ensembl.vep.config.report import REPORT_FORMATS 

25from ensembl.vep.config.sections.base import ConfigSection 

26 

27__all__ = ["BenchConfig"] 

28 

29 

30@define(frozen=True, kw_only=True, auto_attribs=True) 

31class BenchConfig(ConfigSection): 

32 """How every benchmark is measured and reported. Read by every ``bench`` verb. 

33 

34 Attributes: 

35 repeats (int): Timed samples per configuration; the best is reported. 

36 warmup (int): Untimed passes before the first sample. 

37 no_gate (bool): Skip the conformance gate, which otherwise refuses to time anything until 

38 every strategy agrees with the reference. For re-timing a tree already known to conform. 

39 results_file (Path | None): Write the measured results here as JSON. 

40 baseline_file (Path | None): Compare against results previously written here. 

41 regression_threshold (float): Fractional slowdown against the baseline that counts as a 

42 regression. 

43 output_format (str | None): Table format. 

44 """ 

45 

46 section_name: ClassVar[str] = "bench" 

47 

48 repeats: int = field(default=3, metadata=option("timed samples per configuration", metavar="N")) 

49 warmup: int = field(default=1, metadata=option("untimed passes before timing", metavar="N")) 

50 no_gate: bool = field(default=False, metadata=option("skip the conformance gate before timing")) 

51 results_file: Path | None = field(default=None, metadata=option("write results JSON here")) 

52 baseline_file: Path | None = field(default=None, metadata=option("compare against this results JSON")) 

53 regression_threshold: float = field( 

54 default=0.05, metadata=option("fractional slowdown counted as a regression") 

55 ) 

56 output_format: str | None = field( 

57 default=None, 

58 metadata=option("report format (default: text)", choices=REPORT_FORMATS), 

59 )