Update exporter.py

This commit is contained in:
2026-05-06 10:34:10 +07:00
parent 4049e66428
commit e3aea889dd
+63 -40
View File
@@ -212,61 +212,84 @@ def run_process_test(n, proc_count):
def draw_performance_graph(): def draw_performance_graph():
n = 10000 data_sizes = {
proc_counts = list(range(1, 33)) "16": 16,
"64": 64,
"256": 256,
}
times = [] proc_counts = list(range(1, 129))
print("\nBenchmarking process count performance:") print("\nBenchmarking process count performance:")
for p in proc_counts: for label, n in data_sizes.items():
t = run_process_test(n, p) times = []
times.append(t)
print(f"Processes: {p:2d} | Time: {t:.6f} sec")
base_time = times[0] print(f"\nTesting N = {n}:")
speedup = [base_time / t if t > 0 else 0 for t in times] for p in proc_counts:
t = run_process_test(n, p)
times.append(t)
out_path = os.path.join(OUT_DIR, "process_performance.png") print(f"N={n:3d} | Processes: {p:3d} | Time: {t:.6f} sec")
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 6)) base_time = times[0]
# ------------------------- speedup = [base_time / t if t > 0 else 0 for t in times]
# TIME GRAPH
# -------------------------
ax1.plot(proc_counts, times, "o-") out_path = os.path.join(
ax1.set_xlabel("Количество процессов") OUT_DIR,
ax1.set_ylabel("Время (сек)") f"performance_N{n}.png",
ax1.set_title("Время выполнения") )
ax1.grid(True)
# ------------------------- fig, (ax1, ax2) = plt.subplots(
# SPEEDUP GRAPH 1,
# ------------------------- 2,
figsize=(14, 6),
)
ax2.plot(proc_counts, speedup, "s-", label="Реальное ускорение") # --------------------------------
ax2.plot( # EXECUTION TIME
proc_counts, # --------------------------------
proc_counts,
"--",
color="black",
alpha=0.3,
label="Идеал",
)
ax2.set_xlabel("Количество процессов") ax1.plot(proc_counts, times, "o-")
ax2.set_ylabel("Ускорение")
ax2.set_title("Масштабируемость")
ax2.legend()
ax2.grid(True)
plt.tight_layout() ax1.set_xlabel("Количество процессов")
plt.savefig(out_path) ax1.set_ylabel("Время (сек)")
plt.close() ax1.set_title(f"Время выполнения (N = {n})")
ax1.grid(True)
print(f"\nPerformance graph saved to: {out_path}") # --------------------------------
# SPEEDUP
# --------------------------------
ax2.plot(
proc_counts,
speedup,
"s-",
label="Реальное ускорение",
)
ax2.plot(
proc_counts,
proc_counts,
"--",
color="black",
alpha=0.3,
label="Идеал",
)
ax2.set_xlabel("Количество процессов")
ax2.set_ylabel("Ускорение")
ax2.set_title(f"Масштабируемость (N = {n})")
ax2.legend()
ax2.grid(True)
plt.tight_layout()
plt.savefig(out_path)
plt.close()
print(f"Saved: {out_path}")
def main(): def main():