21 from __future__
import print_function
22 from builtins
import str
23 from builtins
import range
27 from dim_labels
import *
32 config_array_dict = dict()
37 Adds results from file to global storage 39 filename -- name of the file which will be used 42 with open(filename)
as temp:
43 json_temp = json.load(temp)
45 simulator = filename.split(
46 "/")[-1].split(
".json")[0].split(
"_")[0].split(
"=")[0].split(
"pynn.")[-1]
49 if simulator
not in SIMULATOR_LABELS:
53 array_nr = filename.split(
"/")[-1].split(
".json")[0].split(
"_")[-1]
54 if not array_nr.isdigit():
57 if simulator
not in results_dict:
58 results_dict[simulator] = dict()
59 results_dict[simulator][array_nr] = json_temp
64 Gathers all results from build directory 67 for filename
in os.listdir(
"../build/"):
69 if filename.endswith(
".json")
and not filename.startswith(
"."):
70 if not filename.endswith(
"_bak.json"):
76 Iterates through the dictionary, gathers all entries with lists 78 dictionary -- dict to iteratively 83 if type(dictionary[i]) == list:
84 temp_dict[i] = dictionary[i]
86 if type(dictionary[i]) == dict:
95 Gathers all arrays in configs from config directory 98 for filename
in os.listdir(
"../config/"):
99 if filename.endswith(
".json")
and not filename.startswith(
"."):
100 with open(
"../config/" + filename)
as temp:
101 json_temp = json.load(temp)
102 config_array_dict[filename.split(
108 Get the array names for the title of the table 112 for i
in config_array_dict[snabname]:
113 for j
in config_array_dict[snabname][i]:
115 if not j
in array_names:
116 array_names.append(j)
122 Get the measure names for the title of the table 126 for i
in results_dict:
128 temp = results_dict[i][
"0"]
132 if not j[
"name"] == snabname:
134 for k
in j[
"results"]:
135 array_names.append(k[
"name"] +
" in " + k[
"measures"])
136 if len(array_names) > 0:
143 Write parameters of the benchmark run 145 texfile -- open file descriptor to file 146 snab -- name string of the snab 147 backend -- backend string 148 param_names -- list of array names created by gather_array_names 149 index -- index of the current array entry 152 for i
in param_names:
153 if backend
in config_array_dict[snab]
and i
in config_array_dict[snab][backend]:
155 " & " +
str(config_array_dict[snab][backend][i][
int(index)]))
162 Write results of the benchmark run 164 texfile -- open file descriptor to file 165 snab -- name string of the snab 166 backend -- backend string 167 measures -- list of measure names created by gather_benchmark_measures 168 index -- index of the current array entry 169 got_snab -- boolean wether there was at least one entry 172 for i
in results_dict[backend][index]:
173 if i[
"name"] == snab:
177 for k
in i[
"results"]:
178 if k[
"name"] == j.split(
" in ")[0]:
179 texfile.write(
" & " +
'{:.2f}'.
format(k[
"value"]))
197 if not os.path.exists(
"tables"):
200 for snabname
in config_array_dict:
201 print(
"Constructing ", snabname +
".tex")
205 texfile = open(
"tables/" + snabname +
".tex",
'w')
206 texfile.write(
"\\begin{tabular}{r")
207 for i
in range(0, len(param_names)):
209 for i
in range(0, len(measures)):
211 texfile.write(
"}\n\\toprule\n")
212 texfile.write(
"Platform")
213 for i
in range(0, len(param_names)):
214 texfile.write(
" & " + param_names[i])
215 for i
in range(0, len(measures)):
216 texfile.write(
" & " + measures[i])
218 texfile.write(
"\n\\midrule\n")
221 for backend
in results_dict:
222 texfile.write(backend)
224 for k
in range(0, len(results_dict[backend])):
227 k), snabname, measures, got_snab)
229 texfile.write(
"\\bottomrule\n\end{tabular}")
def get_key_arrays(dictionary)
def assemble_global_dict()
def write_results(texfile, backend, index, snab, measures, got_snab)
def gather_benchmark_measures(snabname)
def get_key_arrays_from_config()
def gather_array_names(snabname)
def write_array_params(texfile, snab, backend, param_names, index)
def result_json_to_global_dict(filename)