MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / main

Function main

scripts/disagg/extract_base_latency.py:32–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30
31
32def main() -> int:
33 args = parse_args()
34 metrics_path = Path(args.metrics)
35 out_path = Path(args.output)
36
37 if not metrics_path.is_file():
38 raise FileNotFoundError(f"metrics file not found: {metrics_path}")
39
40 with metrics_path.open("r", encoding="utf-8") as f:
41 payload = json.load(f)
42
43 requests = payload.get("requests", [])
44 if not isinstance(requests, list):
45 raise ValueError(f"invalid metrics format: requests must be a list, got {type(requests)}")
46
47 global_start_ts = None
48 for item in requests:
49 if isinstance(item, dict) and item.get("client_send_ts") is not None:
50 ts = float(item["client_send_ts"])
51 global_start_ts = ts if global_start_ts is None else min(global_start_ts, ts)
52
53 rows = []
54 for item in requests:
55 if not isinstance(item, dict):
56 continue
57
58 finish_rel = item.get("elapsed_from_global_start_s")
59 if finish_rel is None:
60 finish_ts = item.get("finish_ts")
61 if finish_ts is not None and global_start_ts is not None:
62 finish_rel = float(finish_ts) - float(global_start_ts)
63
64 row = {
65 "finish_time_from_global_start_s": _fmt_float3(finish_rel),
66 "e2e_latency_s": _fmt_float3(item.get("e2e_latency_s")),
67 }
68 rows.append(row)
69
70 out_path.parent.mkdir(parents=True, exist_ok=True)
71 with out_path.open("w", encoding="utf-8", newline="") as f:
72 writer = csv.DictWriter(f, fieldnames=["finish_time_from_global_start_s", "e2e_latency_s"])
73 writer.writeheader()
74 for row in rows:
75 writer.writerow(row)
76
77 print(f"wrote {len(rows)} rows to {out_path}")
78 return 0
79
80
81if __name__ == "__main__":

Callers 1

Calls 6

openMethod · 0.80
appendMethod · 0.80
parse_argsFunction · 0.70
_fmt_float3Function · 0.70
loadMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected