Harden summary.py
Browse files- scripts/summary.py +15 -7
scripts/summary.py
CHANGED
|
@@ -32,7 +32,7 @@ def load_json(path: Path) -> dict | None:
|
|
| 32 |
try:
|
| 33 |
with open(path, encoding="utf-8") as f:
|
| 34 |
return json.load(f)
|
| 35 |
-
except (FileNotFoundError, json.JSONDecodeError):
|
| 36 |
return None
|
| 37 |
|
| 38 |
|
|
@@ -50,7 +50,7 @@ def fmt_with_ci(value: float | None, ci: dict | None, decimals: int = 3) -> str:
|
|
| 50 |
lower = ci["ci_lower"]
|
| 51 |
upper = ci["ci_upper"]
|
| 52 |
return f"{value:.{decimals}f} [{lower:.{decimals}f}, {upper:.{decimals}f}]"
|
| 53 |
-
return
|
| 54 |
|
| 55 |
|
| 56 |
def print_section(title: str):
|
|
@@ -137,7 +137,7 @@ def main():
|
|
| 137 |
d = dims.get(dim_key, {})
|
| 138 |
m = d.get("mean")
|
| 139 |
label = dim_key.title()
|
| 140 |
-
print(f" {label + ':':<15s} {fmt(m, 2)
|
| 141 |
if overall is not None:
|
| 142 |
status = "PASS" if human.get("pass", False) else "FAIL"
|
| 143 |
print(
|
|
@@ -160,7 +160,10 @@ def main():
|
|
| 160 |
n = delta.get("n_samples", 0)
|
| 161 |
print(f" With evidence: {fmt(with_ev, 3)}")
|
| 162 |
print(f" Without: {fmt(without_ev, 3)}")
|
| 163 |
-
|
|
|
|
|
|
|
|
|
|
| 164 |
else:
|
| 165 |
print(" (not available)")
|
| 166 |
|
|
@@ -187,10 +190,15 @@ def main():
|
|
| 187 |
n = load.get("total_requests", 0)
|
| 188 |
hits = load.get("cache_hits", 0)
|
| 189 |
hit_rate = hits / n if n > 0 else 0
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
|
|
|
|
|
|
|
|
|
| 193 |
print(f" Cache hits: {hits}/{n} ({hit_rate * 100:.0f}%)")
|
|
|
|
|
|
|
| 194 |
else:
|
| 195 |
print(" (not available)")
|
| 196 |
|
|
|
|
| 32 |
try:
|
| 33 |
with open(path, encoding="utf-8") as f:
|
| 34 |
return json.load(f)
|
| 35 |
+
except (FileNotFoundError, json.JSONDecodeError, OSError):
|
| 36 |
return None
|
| 37 |
|
| 38 |
|
|
|
|
| 50 |
lower = ci["ci_lower"]
|
| 51 |
upper = ci["ci_upper"]
|
| 52 |
return f"{value:.{decimals}f} [{lower:.{decimals}f}, {upper:.{decimals}f}]"
|
| 53 |
+
return fmt(value, decimals)
|
| 54 |
|
| 55 |
|
| 56 |
def print_section(title: str):
|
|
|
|
| 137 |
d = dims.get(dim_key, {})
|
| 138 |
m = d.get("mean")
|
| 139 |
label = dim_key.title()
|
| 140 |
+
print(f" {label + ':':<15s} {fmt(m, 2)}")
|
| 141 |
if overall is not None:
|
| 142 |
status = "PASS" if human.get("pass", False) else "FAIL"
|
| 143 |
print(
|
|
|
|
| 160 |
n = delta.get("n_samples", 0)
|
| 161 |
print(f" With evidence: {fmt(with_ev, 3)}")
|
| 162 |
print(f" Without: {fmt(without_ev, 3)}")
|
| 163 |
+
if d is not None:
|
| 164 |
+
print(f" Delta: {fmt(d, 3)} (+{d * 100:.0f}pp, n={n})")
|
| 165 |
+
else:
|
| 166 |
+
print(f" Delta: (not available, n={n})")
|
| 167 |
else:
|
| 168 |
print(" (not available)")
|
| 169 |
|
|
|
|
| 190 |
n = load.get("total_requests", 0)
|
| 191 |
hits = load.get("cache_hits", 0)
|
| 192 |
hit_rate = hits / n if n > 0 else 0
|
| 193 |
+
if p50 is not None and p95 is not None and p99 is not None:
|
| 194 |
+
print(f" P50: {p50:.0f}ms")
|
| 195 |
+
print(f" P95: {p95:.0f}ms")
|
| 196 |
+
print(f" P99: {p99:.0f}ms (n={n})")
|
| 197 |
+
else:
|
| 198 |
+
print(f" Latency: (not available, n={n})")
|
| 199 |
print(f" Cache hits: {hits}/{n} ({hit_rate * 100:.0f}%)")
|
| 200 |
+
status = "PASS" if load.get("pass") else "FAIL"
|
| 201 |
+
print(f" Status: {status}")
|
| 202 |
else:
|
| 203 |
print(" (not available)")
|
| 204 |
|