50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
|
from go_benchmark_functions import *
|
||
|
from inspect import getmro, isclass
|
||
|
|
||
|
_looky_here = False
|
||
|
|
||
|
problems = []
|
||
|
for k in list(locals().keys()):
|
||
|
smth = locals()[k]
|
||
|
if isclass(smth) and Benchmark in getmro(smth)[1:]:
|
||
|
problems.append(smth)
|
||
|
|
||
|
counts = {}
|
||
|
vcount = 0
|
||
|
problems_by_dimensions = {}
|
||
|
|
||
|
for cls in problems:
|
||
|
name = cls.__name__
|
||
|
obj = cls()
|
||
|
n = obj.N
|
||
|
if _looky_here:
|
||
|
print(n, name, "(variable)" if obj.change_dimensionality else "(fixed)")
|
||
|
counts[n] = counts.get(n, 0) + 1
|
||
|
if obj.change_dimensionality:
|
||
|
vcount += 1
|
||
|
dimkey = f"{n}+"
|
||
|
else:
|
||
|
dimkey = f"{n}"
|
||
|
problems_by_dimensions.setdefault(dimkey, []).append(cls)
|
||
|
del obj
|
||
|
|
||
|
counts["variable"] = vcount
|
||
|
|
||
|
if _looky_here:
|
||
|
print(sorted(counts.items(), key=lambda x: f"{x[0]:09}" if isinstance(x[0], int) else str(x[0])))
|
||
|
|
||
|
p_by_d = problems_by_dimensions
|
||
|
|
||
|
if _looky_here:
|
||
|
for dims in range(2, 6 + 1):
|
||
|
dimp = f"{dims}+"
|
||
|
print(dims, len(p_by_d.get(str(dims), [])), sep="\t")
|
||
|
print(dimp, len(p_by_d.get(dimp, [])), sep="\t")
|
||
|
|
||
|
at_least_2d = p_by_d.get("2+", [])
|
||
|
at_least_3d = p_by_d.get("3+", []) + at_least_2d
|
||
|
at_least_4d = p_by_d.get("4+", []) + at_least_3d
|
||
|
problems_2d = p_by_d.get("2", []) + at_least_2d
|
||
|
problems_3d = p_by_d.get("3", []) + at_least_3d
|
||
|
problems_4d = p_by_d.get("4", []) + at_least_4d
|