feat: port lab3 backend foundation to lab4
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
|
||||
#!/usr/bin/env python3
|
||||
"""Create charts from real Track 1 summary.csv data; does not invent measurements."""
|
||||
|
||||
import csv
|
||||
from pathlib import Path
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
source = root / 'evidence' / 'scaling' / 'summary.csv'
|
||||
|
||||
if not source.exists():
|
||||
raise SystemExit('Run scripts/run-scaling-experiment.py first')
|
||||
|
||||
with source.open(encoding='utf-8', newline='') as f:
|
||||
rows = list(csv.DictReader(f))
|
||||
|
||||
if not rows:
|
||||
raise SystemExit('summary.csv is empty')
|
||||
|
||||
out = source.parent
|
||||
|
||||
for key, title, ylabel, filename in [
|
||||
('successful_rps', 'Track 1: successful throughput',
|
||||
'Successful requests/sec', 'throughput.png'),
|
||||
('p95_ms', 'Track 1: p95 latency',
|
||||
'Milliseconds', 'p95-latency.png'),
|
||||
('error_ratio', 'Track 1: error ratio',
|
||||
'Error ratio', 'errors.png'),
|
||||
]:
|
||||
labels = [r['scenario'] for r in rows]
|
||||
values = [float(r[key]) if r[key] else 0 for r in rows]
|
||||
|
||||
plt.figure(figsize=(11, 5))
|
||||
plt.bar(labels, values)
|
||||
|
||||
if key == 'error_ratio':
|
||||
plt.ylim(0, 0.01)
|
||||
for i, value in enumerate(values):
|
||||
plt.text(
|
||||
i, 0.0002, f'{value:.1%}',
|
||||
ha='center', va='bottom'
|
||||
)
|
||||
|
||||
plt.title(title)
|
||||
plt.ylabel(ylabel)
|
||||
plt.xticks(rotation=25, ha='right')
|
||||
plt.tight_layout()
|
||||
plt.savefig(out / filename, dpi=160)
|
||||
plt.close()
|
||||
|
||||
print('Charts written to', out)
|
||||
Reference in New Issue
Block a user