File size: 1,006 Bytes
9398fb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
"""Parse ``Task  N:`` lines from pi05_final suite summary txt files."""

from __future__ import annotations

import re
from pathlib import Path


_TASK_LINE = re.compile(r"^Task\s+(\d+):\s+\d+/\d+\s*=\s*[\d.]+%\s*\|\s*(.+)$", re.MULTILINE)


def parse_suite_summary(path: Path, suite_name: str) -> dict[int, str]:
    text = path.read_text(encoding="utf-8")
    marker = f"PER-TASK SUCCESS RATE SUMMARY ({suite_name})"
    if marker not in text:
        raise ValueError(f"{path}: missing section {suite_name!r}")
    start = text.index(marker) + len(marker)
    rest = text[start:]
    end = rest.find("PER-TASK SUCCESS RATE SUMMARY (")
    section = rest if end < 0 else rest[:end]
    out: dict[int, str] = {}
    for m in _TASK_LINE.finditer(section):
        out[int(m.group(1))] = m.group(2).strip()
    return out


def report_task_to_slot(report_task: int) -> int:
    """Map report line ``Task N`` → benchmark ``get_task(N - 1)`` index."""
    return int(report_task) - 1