diff --git a/tools/plot_track1.py b/tools/plot_track1.py index a04d08b8..d38d767e 100644 --- a/tools/plot_track1.py +++ b/tools/plot_track1.py @@ -156,8 +156,6 @@ def lines(axis, keys, groups, field, categorical=False): markeredgewidth=1.5, **look, ) - if not categorical: - direct_label(axis, rates[-1], values[-1][0], label(key)) if categorical: axis.set_xticks(range(len(keys)), [label(k) for k in keys], rotation=25, ha="right") @@ -174,14 +172,15 @@ def throughput(series, keys, groups, out): axes[0].set_title("Успешные RPS") for axis, field, title in ((axes[1], "p95_ms", "p95, мс"), (axes[2], "p99_ms", "p99, мс")): lines(axis, keys, groups, field, categorical) - axis.set_yscale("log") + if not categorical: + axis.set_yscale("log") axis.set_title(title) for axis in axes: axis.set_xlabel( f"Вариант при {top} запросах/с" if categorical else "Предложенная нагрузка, запросов/с" ) if not categorical: - axis.legend(loc="upper left", fontsize=9) + axis.legend(loc="best", fontsize=9) figure.suptitle(f"{series}: медиана повторов, усы — min–max", color=INK) save(figure, out / f"{series}-throughput.png") @@ -193,13 +192,22 @@ def cpu(series, keys, groups, out): first = groups[key][rates[0]][0] limit = int(first["replicas"]) * float(first["cpus"]) * 100 for index, (field, name) in enumerate(COMPONENTS): - values = [med(groups[key][rate], f"cpu_{field}")[0] for rate in rates] - axis.plot(rates, values, color=PALETTE[index], marker=MARKERS[index], label=name) + values = [med(groups[key][rate], f"cpu_{field}") for rate in rates] + axis.errorbar( + rates, + [v[0] for v in values], + yerr=[[v[1] for v in values], [v[2] for v in values]], + capsize=3, + color=PALETTE[index], + marker=MARKERS[index], + label=name, + ) axis.axhline(limit, color=PALETTE[0], linestyle=":", linewidth=1.2, label="лимит API") axis.axhline(200, color=PALETTE[1], linestyle=":", linewidth=1.2, label="лимит PostgreSQL") axis.set_title(f"CPU, % ядра — {label(key)}") axis.set_xlabel("Предложенная нагрузка, запросов/с") - axis.legend(fontsize=8, loc="upper left") + axis.legend(fontsize=8, loc="best") + figure.suptitle("Медиана CPU по повторам, усы — min–max", color=INK) save(figure, out / f"{series}-cpu.png") @@ -254,13 +262,23 @@ def scaling(rows, out): r = by.get(("series-a", config)) if r: look = style(config) - axis.plot(4, r["peak_ok_rps"], linestyle="none", label=f"серия A: {config}", **look) + axis.errorbar( + 4, + r["peak_ok_rps"], + yerr=[[r["peak_ok_rps"] - r["peak_ok_min"]], [r["peak_ok_max"] - r["peak_ok_rps"]]], + capsize=3, + linestyle="none", + label=f"серия A: {config}", + **look, + ) after = [r for r in rows if r["variant"] == "after"] for r in after: width = r["cpu_api_limit"] / 100 - axis.plot( + axis.errorbar( width, r["peak_ok_rps"], + yerr=[[r["peak_ok_rps"] - r["peak_ok_min"]], [r["peak_ok_max"] - r["peak_ok_rps"]]], + capsize=3, linestyle="none", label=f"{r['config']} после улучшения", **VARIANTS["after"], @@ -269,7 +287,7 @@ def scaling(rows, out): axis.set_ylabel("Пик успешных RPS") axis.set_title("Пропускная способность от ресурсов API") axis.set_xticks(cpus) - axis.legend(loc="upper left", fontsize=9) + axis.legend(loc="best", fontsize=9) save(figure, out / "scaling.png") return fit