MCPcopy Create free account
hub / github.com/1jehuang/jcode / parse_startup_profile

Function parse_startup_profile

scripts/profile_spawn.py:328–351  ·  view source on GitHub ↗
(log_path: Path)

Source from the content-addressed store, hash-verified

326
327
328def 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# --------------------------------------------------------------------------- #

Callers 1

profile_client_spawnFunction · 0.70

Calls 2

StartupProfileClass · 0.70
searchMethod · 0.45

Tested by

no test coverage detected