aboutsummaryrefslogtreecommitdiff
path: root/benchmarks/plot-benchmarks.py
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-12-17 09:26:53 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-12-17 09:26:53 +0100
commit36f37564cd566e91771cd1f92ac3886917c769d1 (patch)
tree037b21f46dafb4edce8aeef25fc3d6e1d607df12 /benchmarks/plot-benchmarks.py
parentc6ab40b1602443938e431b996b28fb3d888365bb (diff)
downloadnissy-core-36f37564cd566e91771cd1f92ac3886917c769d1.tar.gz
nissy-core-36f37564cd566e91771cd1f92ac3886917c769d1.zip
Update benchmarks
Diffstat (limited to '')
-rw-r--r--benchmarks/plot-benchmarks.py161
1 files changed, 161 insertions, 0 deletions
diff --git a/benchmarks/plot-benchmarks.py b/benchmarks/plot-benchmarks.py
new file mode 100644
index 0000000..b42c4ba
--- /dev/null
+++ b/benchmarks/plot-benchmarks.py
@@ -0,0 +1,161 @@
1import matplotlib.pyplot as plt
2import results_h48
3import results_vcube
4
5# Table sizes in bytes
6
7sizes_h48 = {
8 6: 1897951528,
9 7: 3793842344,
10 8: 7585624040,
11 9: 15169187432,
12 10: 30336314216,
13 11: 60670567784,
14}
15
16sizes_vcube = {
17 112: 2603089920,
18 208: 7809269760,
19 308: 22777036800,
20 404: 34165555200,
21 212: 62474158080,
22}
23
24# Printing tables in markdown format
25
26def print_row(solver_name, solver_size, dict, mul_by_size, superflip_star):
27 if dict is None:
28 return
29 solver_gib = solver_size / (2**30)
30 m = solver_gib if mul_by_size else 1
31 s = " (a) " if superflip_star else " "
32 cols = [f"{solver_name: <10}", f"{solver_gib:>4.1f} Gib"] + [
33 f"{dict[key]*m/25:>8.2f}" if key in dict else " "
34 for key in [17, 18, 19, 20]
35 ] + [
36 f"{dict["superflip"]*m:>9.2f}" if "superflip" in dict else s
37 ]
38 sep = "|"
39 print(sep + sep.join(cols) + sep)
40
41def print_table(h48, vcube, ms, st):
42 vcube = vcube or {}
43 print("| Solver | Size |17 moves|18 moves|19 moves|20 moves|Superflip|")
44 print("|:---------|:-------|-------:|-------:|-------:|-------:|--------:|")
45 print_row("vcube 212", sizes_vcube[212], vcube.get(212), ms, not st)
46 print_row("H48 h11", sizes_h48[11], h48[11], ms, False)
47 print_row("vcube 404", sizes_vcube[404], vcube.get(404), ms, not st)
48 print_row("H48 h10", sizes_h48[10], h48[10], ms, False)
49 print_row("vcube 308", sizes_vcube[308], vcube.get(308), ms, not st)
50 print_row("H48 h9", sizes_h48[9], h48[9], ms, False)
51 print_row("vcube 208", sizes_vcube[208], vcube.get(208), ms, not st)
52 print_row("H48 h8", sizes_h48[8], h48[8], ms, False)
53 print_row("H48 h7", sizes_h48[7], h48[7], ms, False)
54 print_row("vcube 112", sizes_vcube[112], vcube.get(112), ms, not st)
55 print_row("H48 h6", sizes_h48[6], h48[6], ms, False)
56
57print("<details><summary>Single solution, single thread</summary>")
58print()
59print("Time per cube (in seconds, lower is better).")
60print()
61print_table(results_h48.h48_single_thread, results_vcube.vcube_single_thread, False, True)
62print()
63print("Time per cube adjusted for table size (in seconds \\* GiB, lower is better).")
64print()
65print_table(results_h48.h48_single_thread, results_vcube.vcube_single_thread, True, True)
66print()
67print(
68 '<img src="img/17moves1thread.png">\n'
69 '<img src="img/18moves1thread.png">\n'
70 '<img src="img/19moves1thread.png">\n'
71 '<img src="img/20moves1thread.png">\n'
72)
73print("</details>")
74
75print("<details><summary>Single solution, 4 threads</summary>")
76print()
77print("Time per cube (in seconds, lower is better).")
78print()
79print_table(results_h48.h48_4_threads, results_vcube.vcube_4_threads, False, False)
80print()
81print("Time per cube adjusted for table size (in seconds \\* GiB, lower is better).")
82print()
83print_table(results_h48.h48_4_threads, results_vcube.vcube_4_threads, True, False)
84print()
85print(
86 '<img src="img/17moves4threads.png">\n'
87 '<img src="img/18moves4threads.png">\n'
88 '<img src="img/19moves4threads.png">\n'
89 '<img src="img/20moves4threads.png">\n'
90)
91print()
92print("(a) vcube cannot parallelize on a single scramble, the results for the")
93print("superflip are going to be the same as in the single thread case.")
94print("</details>")
95
96print("<details><summary>Single solution, 16 threads</summary>")
97print()
98print("Time per cube (in seconds, lower is better).")
99print()
100print_table(results_h48.h48_16_threads, results_vcube.vcube_16_threads, False, False)
101print()
102print("Time per cube adjusted for table size (in seconds \\* GiB, lower is better).")
103print()
104print_table(results_h48.h48_16_threads, results_vcube.vcube_16_threads, True, False)
105print()
106print(
107 '<img src="img/17moves16threads.png">\n'
108 '<img src="img/18moves16threads.png">\n'
109 '<img src="img/19moves16threads.png">\n'
110 '<img src="img/20moves16threads.png">\n'
111)
112print()
113print("(a) vcube cannot parallelize on a single scramble, the results for the")
114print("superflip are going to be the same as in the single thread case.")
115print("</details>")
116
117print("<details><summary>All solutions, 16 threads</summary>")
118print()
119print("*Note: vcube does not have an option for finding multiple solutions.*")
120print()
121print("Time per cube (in seconds, lower is better).")
122print()
123print_table(results_h48.h48_all_solutions, None, False, False)
124print()
125print("Time per cube adjusted for table size (in seconds \\* GiB, lower is better).")
126print()
127print_table(results_h48.h48_all_solutions, None, True, False)
128print()
129print("</details>")
130
131# Plotting
132
133def plot(title, hd, vd, key):
134 d = 1 if key == "superflip" else 25
135 h48x = [sizes_h48[m]/(2**30) for m in hd.keys() if key in hd[m]]
136 vcubex = [sizes_vcube[m]/(2**30) for m in vd.keys() if key in vd[m]]
137 h48y = [d[key] for _, d in hd.items() if key in d]
138 vcubey = [d[key] for _, d in vd.items() if key in d]
139
140 plt.clf()
141 plt.title(title)
142 plt.xlabel("Table size (GiB)")
143 plt.ylabel("Time to solve (s / cube)")
144 plt.plot(h48x, h48y, "o--", label = "H48")
145 plt.plot(vcubex, vcubey, "o--", label = "vcube")
146 plt.legend(loc = "right")
147 filename = title.replace(" ", "").replace(",", "") + ".png"
148 plt.savefig("benchmarks/img/" + filename, dpi=300)
149 #plt.show()
150
151rh, rv = results_h48.h48_single_thread, results_vcube.vcube_single_thread
152for m in [17, 18, 19, 20]:
153 plot(f"{m} moves 1 thread", rh, rv, m)
154
155rh, rv = results_h48.h48_4_threads, results_vcube.vcube_4_threads
156for m in [17, 18, 19, 20]:
157 plot(f"{m} moves 4 threads", rh, rv, m)
158
159rh, rv = results_h48.h48_16_threads, results_vcube.vcube_16_threads
160for m in [17, 18, 19, 20]:
161 plot(f"{m} moves 16 threads", rh, rv, m)

Generated with cgit - Back to sebastiano.tronto.net