1 import matplotlib.pyplot
as plt
2 import csv, sys, numpy
as np
7 with open(filename,
"r") as file: 8 reader = csv.reader(file, strict=True)
12 if fieldnames
is None:
13 fieldnames = [n.strip()
for n
in row]
14 values = [[]
for _
in fieldnames]
17 values[0].append(int(row[0]))
18 for i, v
in enumerate(row[1:]):
19 values[i + 1].append(float(v))
27 for _
in fieldnames[4:]
34 for _
in fieldnames[4:]
40 for i, id
in enumerate(values[0]):
43 for i, id
in enumerate(values[0]):
44 for k, n
in enumerate(fieldnames[4:]):
46 means[k][id] += v / nb_occurence[id]
47 stddevs[k][id] += v * v / nb_occurence[id]
49 for k, n
in enumerate(fieldnames[4:]):
53 stddevs[k][id] = sqrt(stddevs[k][id] - means[k][id] * means[k][id])
59 time_vs_sep_axis =
True 60 nb_occ_sep_axis =
False 61 avg_time_vs_impl =
True 65 plt.subplot(Nrows, Ncols, iplot)
68 plt.title(
"Time, with std dev, versus separating axis")
69 for k, n
in enumerate(fieldnames[4:]):
71 plt.errorbar(np.linspace(0, 11, 12), means[k], stddevs[k], label=n)
73 plt.xlim([-0.5, 11.5])
74 plt.ylabel(
"Time (ns)")
75 plt.xlabel(
"Separating axis")
76 plt.legend(loc=
"upper left")
78 axx = plt.gca().twinx()
81 bins=[i - 0.5
for i
in range(13)],
86 label=
"Cumulative occurence",
88 axx.set_ylabel(
"Nb occurence of a separating axis.")
89 plt.legend(loc=
"lower right")
94 plt.subplot(Nrows, Ncols, iplot)
97 plt.title(
"Nb of occurence per separating axis")
98 plt.hist(values[0], bins=[i - 0.5
for i
in range(13)])
99 plt.ylabel(
"Nb occurence")
100 plt.xlabel(
"Separating axis")
110 plt.subplot(Nrows, Ncols, iplot)
113 plt.title(
"Average time versus the implementation")
115 _mins = np.min(values[4:], axis=1)
116 _maxs = np.max(values[4:], axis=1)
117 _means = np.mean(values[4:], axis=1)
118 _stddev = np.std(values[4:], axis=1)
120 zip(fieldnames[4:], _means, _stddev, _mins, _maxs), key=
lambda x: x[1]
123 [f
for f, m, s, l, u
in _sorted],
124 [m
for f, m, s, l, u
in _sorted],
125 [s
for f, m, s, l, u
in _sorted],
128 label=
"mean and std deviation",
131 [f
for f, m, s, l, u
in _sorted],
132 [l
for f, m, s, l, u
in _sorted],
138 [f
for f, m, s, l, u
in _sorted],
139 [u
for f, m, s, l, u
in _sorted],
144 plt.ylabel(
"Time (ns)")
145 plt.xticks(rotation=20)