forked from mtusi2026/mtusi2026lab3
bench: трек 1 — профили py-spy до/после, серия E (потолок нового пути), графики
Профиль при 240 req/s: доля psycopg 52.7 % -> 19.0 %, активных сэмплов 3889 -> 2026. Серия E: function в 2x1.0 CPU — потолок 552 (530–552) успешных/с, упор в CPU API; в 3x1.0 / БД 0.5 — ~420–460, упор в БД. analyze.py: линии без заливки, цвет = конфигурация, пунктир = multi, подпись — максимум серии. REPORT: раздел трека 1 и ограничения. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
479cd78f7f
commit
b9f1ad58f9
+17
-11
@@ -109,9 +109,9 @@ def svg_chart(title: str, series: dict[str, list[dict]], path: Path, y_key: str
|
||||
sy = lambda v: height - bottom - v / y1 * (height - top - bottom) # noqa: E731
|
||||
out = [f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {width} {height}" font-family="system-ui, sans-serif" font-size="12">',
|
||||
"<style>.bg{fill:#fcfcfb}.ink{fill:#0b0b0b}.ink2{fill:#52514e}.grid{stroke:#e4e3df}.ref{stroke:#b5b3ac}"
|
||||
+ "".join(f".s{i}{{stroke:{c[0]};fill:{c[0]}}}" for i, c in enumerate(SERIES_COLORS))
|
||||
+ "".join(f".l{i}{{stroke:{c[0]};fill:none}}.d{i}{{fill:{c[0]};stroke:#fcfcfb}}" for i, c in enumerate(SERIES_COLORS))
|
||||
+ "@media (prefers-color-scheme: dark){.bg{fill:#1a1a19}.ink{fill:#fff}.ink2{fill:#c3c2b7}.grid{stroke:#34332f}.ref{stroke:#6b6a64}"
|
||||
+ "".join(f".s{i}{{stroke:{c[1]};fill:{c[1]}}}" for i, c in enumerate(SERIES_COLORS)) + "}</style>",
|
||||
+ "".join(f".l{i}{{stroke:{c[1]}}}.d{i}{{fill:{c[1]};stroke:#1a1a19}}" for i, c in enumerate(SERIES_COLORS)) + "}</style>",
|
||||
f'<rect class="bg" width="{width}" height="{height}"/>',
|
||||
f'<text class="ink" x="{left}" y="22" font-size="14" font-weight="600">{title}</text>']
|
||||
step = nice_step(y1)
|
||||
@@ -126,21 +126,27 @@ def svg_chart(title: str, series: dict[str, list[dict]], path: Path, y_key: str
|
||||
out.append(f'<text class="ink2" transform="translate(16 {(top + height - bottom) / 2}) rotate(-90)" text-anchor="middle">{y_label}</text>')
|
||||
if diagonal:
|
||||
out.append(f'<line class="ref" x1="{sx(0):.1f}" y1="{sy(0):.1f}" x2="{sx(max(xs)):.1f}" y2="{sy(max(xs)):.1f}" stroke-width="1"/>')
|
||||
out.append(f'<text class="ink2" x="{sx(max(xs)) - 4:.1f}" y="{sy(max(xs)) - 6:.1f}" text-anchor="end">обслужено = предложено</text>')
|
||||
mid = min(xs) + 0.25 * (max(xs) - min(xs))
|
||||
out.append(f'<text class="ink2" x="{sx(mid) - 6:.1f}" y="{sy(mid) - 8:.1f}" text-anchor="end">обслужено = предложено</text>')
|
||||
legend_y = top + 10
|
||||
for i, (name, pts) in enumerate(series.items()):
|
||||
cls = f"s{i}"
|
||||
# Colour = resource configuration; line style = write path (dashed = old `multi`), so an
|
||||
# A/B pair of one configuration shares a hue and reads as "before / after".
|
||||
bases = list(dict.fromkeys(name.split(", запись")[0] for name in series))
|
||||
for name, pts in series.items():
|
||||
i = bases.index(name.split(", запись")[0])
|
||||
dash = ' stroke-dasharray="6 4"' if name.endswith("запись multi") else ""
|
||||
line_cls, dot_cls = f"l{i}", f"d{i}"
|
||||
line = " ".join(f"{sx(p['rate']):.1f},{sy(p[y_key]):.1f}" for p in pts)
|
||||
out.append(f'<polyline class="{cls}" points="{line}" fill="none" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/>')
|
||||
out.append(f'<polyline class="{line_cls}" points="{line}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"{dash}/>')
|
||||
for p in pts:
|
||||
if "lo" in p and y_key == "ok":
|
||||
out.append(f'<line class="{cls}" x1="{sx(p["rate"]):.1f}" x2="{sx(p["rate"]):.1f}" y1="{sy(p["lo"]):.1f}" y2="{sy(p["hi"]):.1f}" stroke-width="2" opacity="0.5"/>')
|
||||
out.append(f'<line class="{line_cls}" x1="{sx(p["rate"]):.1f}" x2="{sx(p["rate"]):.1f}" y1="{sy(p["lo"]):.1f}" y2="{sy(p["hi"]):.1f}" stroke-width="2" opacity="0.5"/>')
|
||||
tip = (f"{name}: предложено {p['rate']}/с, успешно {p[y_key]:g}/с" + (f" (повторы {p['lo']:g}–{p['hi']:g})" if "lo" in p else "")
|
||||
+ (f", p95 {p['p95']:.0f} мс" if p.get("p95") else ""))
|
||||
out.append(f'<circle class="{cls}" cx="{sx(p["rate"]):.1f}" cy="{sy(p[y_key]):.1f}" r="4" stroke="#fcfcfb" stroke-width="2"><title>{tip}</title></circle>')
|
||||
last = pts[-1]
|
||||
out.append(f'<text class="ink2" x="{sx(last["rate"]) + 8:.1f}" y="{sy(last[y_key]) + 4:.1f}">{last[y_key]:.0f}</text>')
|
||||
out.append(f'<line class="{cls}" x1="{width - right + 34}" x2="{width - right + 52}" y1="{legend_y}" y2="{legend_y}" stroke-width="2"/>')
|
||||
out.append(f'<circle class="{dot_cls}" cx="{sx(p["rate"]):.1f}" cy="{sy(p[y_key]):.1f}" r="4" stroke-width="2"><title>{tip}</title></circle>')
|
||||
peak = max(pts, key=lambda q: q[y_key]) # direct label = the ceiling of this series
|
||||
out.append(f'<text class="ink2" x="{sx(peak["rate"]):.1f}" y="{sy(peak[y_key]) - 10:.1f}" text-anchor="middle">max {peak[y_key]:.0f}</text>')
|
||||
out.append(f'<line class="{line_cls}" x1="{width - right + 34}" x2="{width - right + 52}" y1="{legend_y}" y2="{legend_y}" stroke-width="2"{dash}/>')
|
||||
for k, chunk in enumerate(wrap(name, 22)):
|
||||
out.append(f'<text class="ink" x="{width - right + 58}" y="{legend_y + 4 + 14 * k}">{chunk}</text>')
|
||||
legend_y += 14 * len(wrap(name, 22)) + 12
|
||||
|
||||
Reference in New Issue
Block a user