forked from Pumuckl007/TockBenchmarking
-
Notifications
You must be signed in to change notification settings - Fork 2
/
display_results.py
176 lines (152 loc) · 4.86 KB
/
display_results.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import sys
import numpy as np
import matplotlib.pyplot as plt
class Experiment:
def __init__(self):
self.name = ""
self.description = ""
self.data = []
self.labels = []
def extratMetadata(self, row):
if 'benchmark' in row[0]:
self.name = row[0].replace(":", "").replace("benchmark", "").strip()
def addRow(self, row):
if len(row) < 1:
return
if len(row) == 1:
self.extratMetadata(row)
return
try:
row_data = []
for element in row:
int_val = int(element)
row_data.append(int_val)
self.data.append(row_data)
except Exception:
self.labels = row
def getAverages(self):
if not self.isValid():
return
data_array = np.asarray(self.data)
averages = np.average(data_array, axis=0)
return averages[1:]
def getErrorRange(self):
if not self.isValid():
return
data_array = np.asarray(self.data)
averages = np.average(data_array, axis=0)
deltas = data_array - averages
abs_deltas = np.abs(deltas)
max_deltas = np.max(abs_deltas, axis=0)
return max_deltas[1:]
def isValid(self):
return len(self.data) > 0
def getCloned(self):
new_experiment = Experiment()
new_experiment.labels = self.labels
new_experiment.name = self.name
new_experiment.description = self.description
return new_experiment
def getAveragedData(self):
block = self.data[0][0]
sum = 0
averages = []
blocks = []
count = 0
for datum in self.data:
if block != datum[0]:
averages.append(sum / count)
blocks.append(block)
sum = 0
count = 0
block = datum[0]
sum += datum[2]
count += 1
averages.append(sum / count)
blocks.append(block)
return averages, blocks
def isNewExperiment(row):
if len(row) != 1:
return False
if "benchmark" in row[0]:
return True
return False
def plotExperiments(experiments, labels=None, title="", ylabel=""):
values_count = len(experiments[0].labels) - 1
values = []
errors = []
build_labels = not labels
if not labels:
labels = []
for experiment in experiments:
values.append(experiment.getAverages())
errors.append(experiment.getErrorRange())
if build_labels:
labels.append(experiment.name)
numpy_values = np.asarray(values)
numpy_errors = np.asarray(errors)
width = 1 / (values_count + 1)
numpy_values[0,:] *= 0.1
print(numpy_values)
print(numpy_values[:,0])
for i in range(len(numpy_values[0,:])):
print(i, numpy_values[:][i])
plt.bar(np.arange(len(numpy_values[:,i])) + i * width, numpy_values[:,i], width=width, yerr=numpy_errors[:,i])
plt.title("Time measurement overhead")
plt.ylabel("microseconds / instructions")
if labels:
plt.xticks(range(len(values)), labels)
plt.show()
"""
\begin{table}[h!]
\centering
\begin{tabular}{||c c c c||}
\hline
Col1 & Col2 & Col2 & Col3 \\ [0.5ex]
\hline\hline
1 & 6 & 87837 & 787 \\
2 & 7 & 78 & 5415 \\
3 & 545 & 778 & 7507 \\
4 & 545 & 18744 & 7560 \\
5 & 88 & 788 & 6344 \\ [1ex]
\hline
\end{tabular}
\caption{Table to test captions and labels}
\label{table:1}
\end{table}
"""
def convertToTex(experiments):
width = len(experiments)
height = len(experiments[0].labels)
header = " &"
# for experiment in experiments:
def graphExperiment(experiment):
y, x = experiment.getAveragedData()
x = np.asarray(x)
y = np.asarray(y)
r = np.corrcoef(x, y)
print(r)
plt.title("Time to read flash")
plt.ylabel("milliseconds")
plt.xlabel("kb in icache")
plt.plot(x/1024, y/10000)
plt.show()
def processFile(filename, labels=None, special_handler=None, title="", ylabel=""):
path_root = sys.argv[0].replace("display_results.py", "")
experiment = Experiment()
experiments = []
with open(path_root + "c/data/{}".format(filename), newline="") as csvfile:
for line in csvfile:
row = line.split(",")
if not isNewExperiment(row):
experiment.addRow(row)
else:
if experiment.isValid():
experiments.append(experiment)
experiment = Experiment()
experiment.addRow(row)
if experiment.isValid():
experiments.append(experiment)
# plotExperiments(experiments, labels=labels, title=title, ylabel=ylabel)
graphExperiment(experiments[0])
processFile("icache.log", labels=["microseconds", "instructions"], title="Time measurement overhead", ylabel="microseconds / instructions")