-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_benchmark.py
More file actions
32 lines (26 loc) · 894 Bytes
/
Copy pathplot_benchmark.py
File metadata and controls
32 lines (26 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import csv
import matplotlib.pyplot as plt
def plot_benchmark(csv_file="benchmark_results.csv"):
threads = []
times = []
with open(csv_file, newline='') as f:
reader = csv.DictReader(f)
for row in reader:
threads.append(int(row["threads"]))
times.append(float(row["total_time"]))
unique = {}
for t, time in zip(threads, times):
unique[t] = time
threads_sorted = sorted(unique.keys())
times_sorted = [unique[t] for t in threads_sorted]
plt.figure(figsize=(8, 5))
plt.bar(threads_sorted, times_sorted, width=0.6)
plt.title("Benchmark: Threads vs Total Time")
plt.xlabel("Number of Threads")
plt.ylabel("Total Time (s)")
plt.grid(axis="y", linestyle="--", alpha=0.6)
plt.tight_layout()
plt.savefig("benchmark_plot.png")
plt.show()
if __name__ == "__main__":
plot_benchmark()