MCPcopy Create free account
hub / github.com/FlashSampling/FlashSampling / parse_chrome_trace

Function parse_chrome_trace

benchmarking/parse_proton_intrakernel.py:19–38  ·  view source on GitHub ↗

Parse a chrome trace and return aggregate scope durations (in cycles).

(path: Path)

Source from the content-addressed store, hash-verified

17
18
19def parse_chrome_trace(path: Path) -> dict | None:
20 """Parse a chrome trace and return aggregate scope durations (in cycles)."""
21 path = Path(path)
22 if not path.exists():
23 return None
24 data = json.load(path.open())
25 events = data["traceEvents"]
26 if not events:
27 return None
28
29 scope_dur: dict[str, float] = defaultdict(float)
30 scope_cnt: dict[str, int] = defaultdict(int)
31 for e in events:
32 scope_dur[e["name"]] += e["dur"]
33 scope_cnt[e["name"]] += 1
34
35 total = sum(scope_dur.values())
36 if total == 0:
37 return None
38 return {"scopes": dict(scope_dur), "counts": dict(scope_cnt), "total_cycles": total}
39
40
41def trace_phase_pcts(trace: dict) -> dict[str, float]:

Callers 2

load_dataFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected