MCPcopy Create free account
hub / github.com/FastMAS/KVCOMM / _write_per_agent_latency

Function _write_per_agent_latency

experiments/benchmark_TTFT.py:119–142  ·  view source on GitHub ↗
(output_dir: str)

Source from the content-addressed store, hash-verified

117
118
119def _write_per_agent_latency(output_dir: str) -> None:
120 latency_path = Path(output_dir) / "Latency.json"
121 if not latency_path.exists():
122 logger.warning("Latency.json not found at {}", str(latency_path))
123 return
124 try:
125 with open(latency_path, "r", encoding="utf-8") as f:
126 records = json.load(f)
127 except Exception as e:
128 logger.warning("Could not read Latency.json: {}", e)
129 return
130 by_agent: Dict[str, List[Dict[str, Any]]] = {}
131 for rec in records if isinstance(records, list) else []:
132 agent_id = rec.get("agent_id") or "unknown"
133 by_agent.setdefault(agent_id, []).append(rec)
134 out_dir = Path(output_dir) / "agent_latency"
135 out_dir.mkdir(parents=True, exist_ok=True)
136 for agent_id, items in by_agent.items():
137 agent_file = out_dir / f"agent_{agent_id}.json"
138 with open(agent_file, "w", encoding="utf-8") as f:
139 json.dump(items, f, ensure_ascii=False, indent=2)
140 combined = out_dir / "PerAgentLatency.json"
141 with open(combined, "w", encoding="utf-8") as f:
142 json.dump(by_agent, f, ensure_ascii=False, indent=2)
143
144async def main():
145 args = parse_args()

Callers 1

evaluateFunction · 0.85

Calls 3

setdefaultMethod · 0.80
itemsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected