add level 5
This commit is contained in:
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Renders Track 1 raw JSON results into a small dependency-free SVG chart."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
ORDER = ["fixed-1", "fixed-2", "fixed-4", "growth-2", "growth-4"]
|
||||
COLORS = {"fixed": "#2563eb", "growth": "#16a34a"}
|
||||
|
||||
|
||||
def main() -> None:
|
||||
raw = ROOT / "evidence" / "track1" / "raw"
|
||||
values = []
|
||||
for label in ORDER:
|
||||
data = json.loads((raw / f"{label}.json").read_text(encoding="utf-8"))
|
||||
values.append((label, data["load"]["successful_rps"], data["load"]["successful_latency_ms"]["p95"]))
|
||||
maximum = max(value for _, value, _ in values)
|
||||
width, height, bottom, chart_height = 820, 430, 355, 270
|
||||
bars = []
|
||||
for index, (label, rps, p95) in enumerate(values):
|
||||
x = 70 + index * 145
|
||||
bar_height = round(rps / maximum * chart_height)
|
||||
y = bottom - bar_height
|
||||
color = COLORS["fixed" if label.startswith("fixed") else "growth"]
|
||||
bars.append(
|
||||
f'<rect x="{x}" y="{y}" width="90" height="{bar_height}" fill="{color}"/>'
|
||||
f'<text x="{x + 45}" y="{y - 8}" text-anchor="middle">{rps:.1f}</text>'
|
||||
f'<text x="{x + 45}" y="{bottom + 20}" text-anchor="middle">{label}</text>'
|
||||
f'<text x="{x + 45}" y="{bottom + 39}" text-anchor="middle" class="small">p95 {p95:.1f} ms</text>'
|
||||
)
|
||||
ticks = []
|
||||
for value in range(0, int(maximum) + 100, 200):
|
||||
y = bottom - round(value / maximum * chart_height)
|
||||
ticks.append(f'<line x1="55" y1="{y}" x2="790" y2="{y}" class="grid"/><text x="48" y="{y + 4}" text-anchor="end">{value}</text>')
|
||||
svg = f'''<svg xmlns="http://www.w3.org/2000/svg" width="{width}" height="{height}" viewBox="0 0 {width} {height}">
|
||||
<style>text{{font:14px sans-serif;fill:#111827}} .small{{font-size:11px;fill:#4b5563}} .grid{{stroke:#d1d5db;stroke-width:1}} .legend{{font-size:12px}}</style>
|
||||
<rect width="100%" height="100%" fill="white"/>
|
||||
<text x="55" y="28" font-size="20" font-weight="bold">Track 1: successful RPS (closed-loop POST, concurrency 32)</text>
|
||||
<text x="55" y="50" class="small">Blue: fixed API total 2 CPU / 1024 MiB. Green: API total 4 CPU / 2048 MiB.</text>
|
||||
{''.join(ticks)}
|
||||
<line x1="55" y1="{bottom}" x2="790" y2="{bottom}" stroke="#111827"/>
|
||||
{''.join(bars)}
|
||||
<text x="55" y="405" class="small">Data: evidence/track1/raw/*.json. Each point uses a fresh database volume; DB limit 0.75 CPU / 512 MiB.</text>
|
||||
</svg>'''
|
||||
destination = ROOT / "evidence" / "track1" / "scale.svg"
|
||||
destination.write_text(svg + "\n", encoding="utf-8")
|
||||
print(destination.relative_to(ROOT))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user