various performance work (wip)

This commit is contained in:
Jan Petykiewicz 2026-04-01 21:29:23 -07:00
commit 71e263c527
25 changed files with 4071 additions and 326 deletions

View file

@ -7,7 +7,7 @@ from dataclasses import asdict
from datetime import date
from pathlib import Path
from inire.tests.example_scenarios import SCENARIO_SNAPSHOTS
from inire.tests.example_scenarios import PERFORMANCE_SCENARIO_SNAPSHOTS, SCENARIO_SNAPSHOTS
SUMMARY_METRICS = (
@ -24,10 +24,20 @@ SUMMARY_METRICS = (
)
def _build_payload(selected_scenarios: tuple[str, ...] | None = None) -> dict[str, object]:
def _snapshot_registry(include_performance_only: bool) -> tuple[tuple[str, object], ...]:
if not include_performance_only:
return SCENARIO_SNAPSHOTS
return SCENARIO_SNAPSHOTS + PERFORMANCE_SCENARIO_SNAPSHOTS
def _build_payload(
selected_scenarios: tuple[str, ...] | None = None,
*,
include_performance_only: bool = False,
) -> dict[str, object]:
allowed = None if selected_scenarios is None else set(selected_scenarios)
snapshots = []
for name, run in SCENARIO_SNAPSHOTS:
for name, run in _snapshot_registry(include_performance_only):
if allowed is not None and name not in allowed:
continue
snapshots.append(run())
@ -103,6 +113,11 @@ def main() -> None:
default=[],
help="Optional scenario name to include. May be passed more than once.",
)
parser.add_argument(
"--include-performance-only",
action="store_true",
help="Include performance-only snapshot scenarios that are excluded from the default baseline corpus.",
)
args = parser.parse_args()
repo_root = Path(__file__).resolve().parents[1]
@ -110,7 +125,7 @@ def main() -> None:
docs_dir.mkdir(exist_ok=True)
selected = tuple(args.scenarios) if args.scenarios else None
payload = _build_payload(selected)
payload = _build_payload(selected, include_performance_only=args.include_performance_only)
json_path = docs_dir / "performance_baseline.json"
markdown_path = docs_dir / "performance.md"