#!/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'' f'{rps:.1f}' f'{label}' f'p95 {p95:.1f} ms' ) ticks = [] for value in range(0, int(maximum) + 100, 200): y = bottom - round(value / maximum * chart_height) ticks.append(f'{value}') svg = f''' Track 1: successful RPS (closed-loop POST, concurrency 32) Blue: fixed API total 2 CPU / 1024 MiB. Green: API total 4 CPU / 2048 MiB. {''.join(ticks)} {''.join(bars)} Data: evidence/track1/raw/*.json. Each point uses a fresh database volume; DB limit 0.75 CPU / 512 MiB. ''' destination = ROOT / "evidence" / "track1" / "scale.svg" destination.write_text(svg + "\n", encoding="utf-8") print(destination.relative_to(ROOT)) if __name__ == "__main__": main()