MCPcopy Index your code
hub / github.com/IBM/AssetOpsBench / aggregate_ops

Function aggregate_ops

src/evaluation/metrics.py:169–183  ·  view source on GitHub ↗
(results: list[ScenarioResult])

Source from the content-addressed store, hash-verified

167
168
169def aggregate_ops(results: list[ScenarioResult]) -> AggregateOps:
170 if not results:
171 return AggregateOps()
172
173 durations = [r.ops.duration_ms for r in results if r.ops.duration_ms is not None]
174 costs = [r.ops.est_cost_usd for r in results if r.ops.est_cost_usd is not None]
175
176 return AggregateOps(
177 tokens_in_total=sum(r.ops.tokens_in for r in results),
178 tokens_out_total=sum(r.ops.tokens_out for r in results),
179 duration_ms_p50=_percentile(durations, 50),
180 duration_ms_p95=_percentile(durations, 95),
181 tool_calls_total=sum(r.ops.tool_call_count for r in results),
182 est_cost_usd_total=round(sum(costs), 6) if costs else None,
183 )
184
185
186def _percentile(values: list[float], pct: float) -> float | None:

Callers 4

test_emptyMethod · 0.90
build_reportFunction · 0.85

Calls 2

AggregateOpsClass · 0.85
_percentileFunction · 0.85

Tested by 3

test_emptyMethod · 0.72