(log_path: Path)
| 326 | |
| 327 | |
| 328 | def parse_startup_profile(log_path: Path) -> StartupProfile | None: |
| 329 | if not log_path.exists(): |
| 330 | return None |
| 331 | lines = log_path.read_text(errors="replace").splitlines() |
| 332 | last_block: list[str] = [] |
| 333 | remote_history_ms = None |
| 334 | for i, line in enumerate(lines): |
| 335 | if "=== Startup Profile (" in line: |
| 336 | last_block = lines[i : i + 40] |
| 337 | m = REMOTE_HISTORY_RE.search(line) |
| 338 | if m: |
| 339 | remote_history_ms = float(m.group(1)) |
| 340 | if not last_block: |
| 341 | return None |
| 342 | prof = StartupProfile(remote_history_ms=remote_history_ms) |
| 343 | for line in last_block: |
| 344 | tm = PROFILE_TOTAL_RE.search(line) |
| 345 | if tm: |
| 346 | prof.total_ms = float(tm.group(1)) |
| 347 | pm = PROFILE_LINE_RE.search(line) |
| 348 | if pm: |
| 349 | _from, delta, name = pm.groups() |
| 350 | prof.deltas_ms[name] = float(delta) |
| 351 | return prof |
| 352 | |
| 353 | |
| 354 | # --------------------------------------------------------------------------- # |
no test coverage detected