Files
mtusi2026lab5/student-tests/plot.py
T

29 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Figures from real accepted/ready and cgroup samples, no synthetic results."""
import json
from pathlib import Path
import statistics
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
r=Path(__file__).resolve().parents[1]/'evidence'
x=json.loads((r/'resources.json').read_text())['experiments']
fig,axes=plt.subplots(1,2,figsize=(11,4.3),layout='constrained')
labels=['320×200\n1,3 KiB','1800×1400\n7,21 MiB','10000×4000\n0,51 MiB']
a=[max(v['accepted_seconds'] for v in e['replies']) for e in x]
b=[max(v['ready_seconds'] for v in e['replies']) for e in x]
axes[0].bar([i-.18 for i in range(3)],a,.36,label='p95 до 202')
axes[0].bar([i+.18 for i in range(3)],b,.36,label='p95 до ready')
axes[0].set(xticks=range(3),xticklabels=labels,ylabel='Секунды',title='10 одновременных загрузок · worker=1')
axes[0].legend()
peak=[int(e['after']['memory.peak'])/1048576 for e in x]
anon=[max(int(dict(line.split() for line in s['worker']['memory.stat'].splitlines())['anon']) for s in e['samples'])/1048576 for e in x]
axes[1].bar([i-.18 for i in range(3)],peak,.36,label='cgroup memory.peak')
axes[1].bar([i+.18 for i in range(3)],anon,.36,label='Пик resident anon')
axes[1].axhline(768,color='#d62728',linestyle='--',label='Лимит worker')
axes[1].set(xticks=range(3),xticklabels=labels,ylabel='MiB',title='Worker + дочерний декодер')
axes[1].legend(fontsize=8)
for ax in axes:ax.grid(axis='y',alpha=.2);ax.set_axisbelow(True)
fig.suptitle('ЛР 5 · реальные измерения · concurrency=1, prefetch=1')
fig.savefig(r/'pipeline.png',dpi=150)
fig.savefig(r/'pipeline.svg')