5 import matplotlib.pyplot
as plt
10 with open(filename,
"r")
as file:
11 reader = csv.reader(file, strict=
True)
15 if fieldnames
is None:
16 fieldnames = [n.strip()
for n
in row]
17 values = [[]
for _
in fieldnames]
20 values[0].append(int(row[0]))
21 for i, v
in enumerate(row[1:]):
22 values[i + 1].append(float(v))
30 for _
in fieldnames[4:]
37 for _
in fieldnames[4:]
43 for i, id
in enumerate(values[0]):
46 for i, id
in enumerate(values[0]):
47 for k, n
in enumerate(fieldnames[4:]):
49 means[k][id] += v / nb_occurence[id]
50 stddevs[k][id] += v * v / nb_occurence[id]
52 for k, n
in enumerate(fieldnames[4:]):
56 stddevs[k][id] = sqrt(stddevs[k][id] - means[k][id] * means[k][id])
62 time_vs_sep_axis =
True
63 nb_occ_sep_axis =
False
64 avg_time_vs_impl =
True
68 plt.subplot(Nrows, Ncols, iplot)
71 plt.title(
"Time, with std dev, versus separating axis")
72 for k, n
in enumerate(fieldnames[4:]):
85 plt.errorbar(np.linspace(0, 11, 12), means[k], stddevs[k], label=n)
92 plt.xlim([-0.5, 11.5])
93 plt.ylabel(
"Time (ns)")
94 plt.xlabel(
"Separating axis")
95 plt.legend(loc=
"upper left")
97 axx = plt.gca().twinx()
100 bins=[i - 0.5
for i
in range(13)],
105 label=
"Cumulative occurence",
107 axx.set_ylabel(
"Nb occurence of a separating axis.")
108 plt.legend(loc=
"lower right")
113 plt.subplot(Nrows, Ncols, iplot)
116 plt.title(
"Nb of occurence per separating axis")
117 plt.hist(values[0], bins=[i - 0.5
for i
in range(13)])
118 plt.ylabel(
"Nb occurence")
119 plt.xlabel(
"Separating axis")
129 plt.subplot(Nrows, Ncols, iplot)
132 plt.title(
"Average time versus the implementation")
134 _mins = np.min(values[4:], axis=1)
135 _maxs = np.max(values[4:], axis=1)
136 _means = np.mean(values[4:], axis=1)
137 _stddev = np.std(values[4:], axis=1)
139 zip(fieldnames[4:], _means, _stddev, _mins, _maxs), key=
lambda x: x[1]
142 [f
for f, _, _, _, _
in _sorted],
143 [m
for _, m, _, _, _
in _sorted],
144 [s
for _, _, s, _, _
in _sorted],
147 label=
"mean and std deviation",
150 [f
for f, _, _, _, _
in _sorted],
151 [v
for _, _, _, v, _
in _sorted],
157 [f
for f, _, _, _, _
in _sorted],
158 [u
for _, _, _, _, u
in _sorted],
163 plt.ylabel(
"Time (ns)")
164 plt.xticks(rotation=20)