From e3aea889dd1e9eb871c71d54dfa2953a374a7a42 Mon Sep 17 00:00:00 2001 From: pajjilykk Date: Wed, 6 May 2026 10:34:10 +0700 Subject: [PATCH] Update exporter.py --- 1/exporter.py | 103 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 40 deletions(-) diff --git a/1/exporter.py b/1/exporter.py index 7804142..33818fc 100644 --- a/1/exporter.py +++ b/1/exporter.py @@ -212,61 +212,84 @@ def run_process_test(n, proc_count): def draw_performance_graph(): - n = 10000 - proc_counts = list(range(1, 33)) + data_sizes = { + "16": 16, + "64": 64, + "256": 256, + } - times = [] + proc_counts = list(range(1, 129)) print("\nBenchmarking process count performance:") - for p in proc_counts: - t = run_process_test(n, p) - times.append(t) - print(f"Processes: {p:2d} | Time: {t:.6f} sec") + for label, n in data_sizes.items(): + times = [] - 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] - # ------------------------- - # TIME GRAPH - # ------------------------- + speedup = [base_time / t if t > 0 else 0 for t in times] - ax1.plot(proc_counts, times, "o-") - ax1.set_xlabel("Количество процессов") - ax1.set_ylabel("Время (сек)") - ax1.set_title("Время выполнения") - ax1.grid(True) + out_path = os.path.join( + OUT_DIR, + f"performance_N{n}.png", + ) - # ------------------------- - # SPEEDUP GRAPH - # ------------------------- + fig, (ax1, ax2) = plt.subplots( + 1, + 2, + figsize=(14, 6), + ) - ax2.plot(proc_counts, speedup, "s-", label="Реальное ускорение") - ax2.plot( - proc_counts, - proc_counts, - "--", - color="black", - alpha=0.3, - label="Идеал", - ) + # -------------------------------- + # EXECUTION TIME + # -------------------------------- - ax2.set_xlabel("Количество процессов") - ax2.set_ylabel("Ускорение") - ax2.set_title("Масштабируемость") - ax2.legend() - ax2.grid(True) + ax1.plot(proc_counts, times, "o-") - plt.tight_layout() - plt.savefig(out_path) - plt.close() + ax1.set_xlabel("Количество процессов") + ax1.set_ylabel("Время (сек)") + 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():