forked from cleveragents/cleveragents-core
50 lines
1.8 KiB
Python
50 lines
1.8 KiB
Python
"""Benchmarks for documentation file reading and validation."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
QUALITY_GUIDE_PATH = Path("docs/development/quality-automation.md")
|
|
TESTING_GUIDE_PATH = Path("docs/development/testing.md")
|
|
README_PATH = Path("README.md")
|
|
CONTRIBUTING_PATH = Path("CONTRIBUTING.md")
|
|
|
|
|
|
class TimeDocsParsing:
|
|
"""Measure documentation file reading and validation performance."""
|
|
|
|
def setup(self) -> None:
|
|
"""Read source files once for reuse."""
|
|
if QUALITY_GUIDE_PATH.exists():
|
|
self.quality_guide_text = QUALITY_GUIDE_PATH.read_text()
|
|
else:
|
|
self.quality_guide_text = ""
|
|
if README_PATH.exists():
|
|
self.readme_text = README_PATH.read_text()
|
|
else:
|
|
self.readme_text = ""
|
|
if CONTRIBUTING_PATH.exists():
|
|
self.contributing_text = CONTRIBUTING_PATH.read_text()
|
|
else:
|
|
self.contributing_text = ""
|
|
|
|
def time_read_quality_guide(self) -> None:
|
|
"""Benchmark reading the quality automation guide."""
|
|
if QUALITY_GUIDE_PATH.exists():
|
|
QUALITY_GUIDE_PATH.read_text()
|
|
|
|
def time_check_guide_links_in_readme(self) -> None:
|
|
"""Benchmark checking quality guide link in README."""
|
|
if self.readme_text:
|
|
_ = "quality-automation.md" in self.readme_text
|
|
|
|
def time_check_guide_links_in_contributing(self) -> None:
|
|
"""Benchmark checking quality guide link in CONTRIBUTING."""
|
|
if self.contributing_text:
|
|
_ = "quality-automation.md" in self.contributing_text
|
|
|
|
def time_count_guide_sections(self) -> None:
|
|
"""Benchmark counting sections in quality guide."""
|
|
if self.quality_guide_text:
|
|
_ = self.quality_guide_text.count("## ")
|