MCPcopy Create free account
hub / github.com/Emmimal/control-layer / latency_stats

Method latency_stats

control_layer.py:763–777  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

761 return sum(1 for r in self._records if r.passed) / len(self._records)
762
763 def latency_stats(self) -> Dict[str, float]:
764 with self._lock:
765 latencies = [r.latency_ms for r in self._records]
766 if not latencies:
767 return {}
768 latencies.sort()
769 n = len(latencies)
770 return {
771 "min": round(latencies[0], 2),
772 "max": round(latencies[-1], 2),
773 "mean": round(sum(latencies) / n, 2),
774 "p50": round(latencies[int(n * 0.50)], 2),
775 "p90": round(latencies[int(n * 0.90)], 2),
776 "p99": round(latencies[min(int(n * 0.99), n - 1)], 2),
777 }
778
779
780# =============================================================================

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected