52 lines
1.9 KiB
Python
52 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Render a small static comparison from the saved raw experiment."""
|
|
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def main():
|
|
source = Path(sys.argv[1])
|
|
data = json.loads(source.read_text())
|
|
summary = data["summary"]
|
|
metrics = [
|
|
("sql_execution_median_ms", "SQL median, ms"),
|
|
("insert_5000_median_seconds", "INSERT 5000 + COMMIT, s"),
|
|
("index_bytes", "Index size, bytes"),
|
|
("insert_wal_median_bytes", "WAL for INSERT 5000, bytes"),
|
|
]
|
|
parts = [
|
|
'<svg xmlns="http://www.w3.org/2000/svg" width="900" height="610" viewBox="0 0 900 610">',
|
|
'<rect width="900" height="610" fill="white"/>',
|
|
'<g font-family="sans-serif" font-size="15" fill="#172033">',
|
|
'<text x="30" y="30" font-size="21">100 000 messages: warm PostgreSQL comparison</text>',
|
|
]
|
|
for i, (key, title) in enumerate(metrics):
|
|
y = 65 + i * 130
|
|
maximum = max(summary[v][key] for v in summary) or 1
|
|
parts.append(f'<text x="30" y="{y}">{title}</text>')
|
|
for j, (variant, color) in enumerate((("chat_only", "#d68439"), ("composite", "#346dc4"))):
|
|
value = summary[variant][key]
|
|
width = 530 * value / maximum
|
|
yy = y + 15 + j * 33
|
|
parts.extend(
|
|
[
|
|
f'<text x="30" y="{yy + 19}">{variant}</text>',
|
|
f'<rect x="140" y="{yy}" width="{width:.2f}" height="24" fill="{color}"/>',
|
|
f'<text x="{150 + width:.2f}" y="{yy + 18}">{value:.6g}</text>',
|
|
]
|
|
)
|
|
parts.extend(
|
|
[
|
|
'<text x="30" y="595">3 phases/index; 7 reads/phase; same data and limits. SQL time is not HTTP time.</text>',
|
|
"</g></svg>",
|
|
]
|
|
)
|
|
source.with_suffix(".svg").write_text("\n".join(parts))
|
|
print("Saved", source.with_suffix(".svg"))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|