forked from mtusi2026/mtusi2026lab3
32 lines
1.1 KiB
Python
Executable File
32 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Собирает итоговую таблицу по прогонам Трека 1 (медиана по повторам)."""
|
|
import json
|
|
import re
|
|
import statistics
|
|
import sys
|
|
from collections import defaultdict
|
|
from pathlib import Path
|
|
|
|
out = Path(sys.argv[1])
|
|
groups = defaultdict(list)
|
|
for f in sorted(out.glob("n*_run*.json")):
|
|
n = int(re.match(r"n(\d+)_", f.name).group(1))
|
|
groups[n].append(json.loads(f.read_text()))
|
|
|
|
lines = ["| Реплик | RPS (мед.) | p50, мс | p95, мс | p99, мс | Ошибок, % |",
|
|
"|---|---|---|---|---|---|"]
|
|
for n in sorted(groups):
|
|
runs = groups[n]
|
|
med = lambda getter: statistics.median(getter(r) for r in runs)
|
|
lines.append("| {} | {:.1f} | {:.1f} | {:.1f} | {:.1f} | {:.2f} |".format(
|
|
n,
|
|
med(lambda r: r["successful_rps"]),
|
|
med(lambda r: r["successful_latency_ms"]["p50"]),
|
|
med(lambda r: r["successful_latency_ms"]["p95"]),
|
|
med(lambda r: r["successful_latency_ms"]["p99"]),
|
|
100 * med(lambda r: r["error_ratio"] or 0),
|
|
))
|
|
text = "\n".join(lines) + "\n"
|
|
(out / "summary.md").write_text(text)
|
|
print(text)
|