-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplot_util.py
More file actions
311 lines (280 loc) · 8.56 KB
/
plot_util.py
File metadata and controls
311 lines (280 loc) · 8.56 KB
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
import pandas
import os
import subprocess
# General configuration.
COLORS = [
"rgb(255,255,106)", # Yellow
"rgb(31,120,180)", # Blue
"rgb(178,223,138)", #
"rgb(51,160,44)",
"rgb(251,154,153)",
"rgb(207,233,252)",
"rgb(188, 189, 34)",
"rgb(23, 190, 207)",
"rgb(240, 74, 62)",
"rgb(23, 190, 207)",
]
plotconfig = {
# "rwlock": {
# "label": "EBR-RQ",
# "color": COLORS[7],
# "symbol": 1,
# "macrobench": "RQ_RWLOCK",
# },
"lockfree": {
"label": "EBR-RQ",
"color": COLORS[1],
"symbol": 0,
"macrobench": "RQ_LOCKFREE",
},
"vcas": {
"label": "vCAS",
"color": COLORS[2],
"symbol": 6,
"macrobench": "RQ_VCAS"
},
"rlu": {
"label": "RLU",
"color": COLORS[4],
"symbol": 3,
"macrobench": "RQ_RLU"
},
"unsafe": {
"label": "Unsafe",
"color": COLORS[5],
"symbol": 4,
"macrobench": "RQ_UNSAFE",
},
"tsbundle": {
"label": "Bundle-RQ",
"color": COLORS[3],
"symbol": 1,
"macrobench": "",
},
"bundle": {
"label": "Bundle",
"color": COLORS[0],
"symbol": 2,
"macrobench": "RQ_BUNDLE",
},
}
def update_opacity(colorstr, opacity):
temp = colorstr.split("(")
return "rgba(" + temp[1][:-1] + ", " + str(opacity) + ")"
relaxconfig = {
"relax1": {
"label": "T=1",
"color": COLORS[0],
"symbol": 1
},
"relax2": {
"label": "T=2",
"color": COLORS[1],
"symbol": 0
},
"relax5": {
"label": "T=5",
"color": COLORS[2],
"symbol": 3
},
# 'relax10': {'color': 'seagreen', 'symbol': 2},
# 'relax20': {'color': 'darkorange', 'symbol': 5},
"relax50": {
"label": "T=50",
"color": COLORS[3],
"symbol": 4
},
"relax100": {
"label": "T=100",
"color": COLORS[4],
"symbol": 6
},
"relax1k": {
"label": "T=1000",
"color": COLORS[5],
"symbol": 7
},
# 'relax10k': {'label': 'T=10000', 'color': COLORS[6], 'symbol': 8},
"ubundle": {
"label": "T=infinity",
"color": COLORS[9],
"symbol": 9
},
}
delayconfig = {
"delay0": {
"label": "d=0ms",
"color": COLORS[0],
"symbol": 1
},
"delay1000": {
"label": "d=1ms",
"color": COLORS[1],
"symbol": 0
},
"delay5000": {
"label": "T=5ms",
"color": COLORS[2],
"symbol": 3
},
"delay10000": {
"label": "T=10ms",
"color": COLORS[3],
"symbol": 4
},
"delay100000": {
"label": "T=100ms",
"color": COLORS[4],
"symbol": 6
},
"nofree": {
"label": "Leaky",
"color": COLORS[5],
"symbol": 7
},
}
separate_unsafe = True
# Global variables used for formatting.
axis_font_ = {}
legend_font_ = {}
x_axis_layout_ = {}
y_axis_layout_ = {}
layout_ = {}
def reset_base_config():
# Clear out any existing values.
axis_font_.clear()
legend_font_.clear()
x_axis_layout_.clear()
y_axis_layout_.clear()
layout_.clear()
# The following should be called before every plot to ensure that there are no changes visible from previous method calls.
axis_font_["family"] = "Times-Roman"
axis_font_["size"] = 72
axis_font_["color"] = "black"
legend_font_["family"] = "Times-Roman"
legend_font_["size"] = 24
legend_font_["color"] = "black"
x_axis_layout_["type"] = "category"
x_axis_layout_["title"] = {"text": ""}
x_axis_layout_["title"]["font"] = axis_font_.copy()
x_axis_layout_["tickfont"] = axis_font_.copy()
x_axis_layout_["zerolinecolor"] = "black"
x_axis_layout_["gridcolor"] = "black"
x_axis_layout_["gridwidth"] = 2
x_axis_layout_["linecolor"] = "black"
x_axis_layout_["linewidth"] = 4
x_axis_layout_["mirror"] = True
y_axis_layout_["title"] = {"text": ""}
y_axis_layout_["title"]["font"] = axis_font_.copy()
y_axis_layout_["tickfont"] = axis_font_.copy()
y_axis_layout_["zerolinecolor"] = "black"
y_axis_layout_["gridcolor"] = "black"
y_axis_layout_["gridwidth"] = 2
y_axis_layout_["linecolor"] = "black"
y_axis_layout_["linewidth"] = 4
y_axis_layout_["mirror"] = True
layout_["xaxis"] = x_axis_layout_
layout_["yaxis"] = y_axis_layout_
layout_["plot_bgcolor"] = "white"
layout_["margin"] = dict(l=0, r=10, t=10, b=0)
def parse_config(filepath):
required_configs = {"maxthreads": int, "threadincrement": int}
config = {}
with open(filepath, "r") as f:
for line in f:
line = line.strip()
if line == "" or line.startswith("#"):
continue
entry = line.split("=", maxsplit=1)
if entry[0] not in required_configs.keys():
continue # Skip irrelevant lines.
config[entry[0]] = required_configs[entry[0]](entry[1])
return config
def parse_experiment_list_generate(filepath, experiment_commands):
experiments = []
configs = {"datastructures": None, "ksizes": None}
done = {"datastructures": False, "ksizes": False}
with open(filepath, "r") as f:
for line in f:
line = line.strip()
if line == "" or line.startswith("#"):
continue
# Check whether this line indicates an experiment to run skip parsing the configuration if so
if len(experiment_commands) > 0:
detected = False
for e in experiment_commands:
if e in line and "#<" in line:
experiments.append(e)
detected = True
break
if detected:
continue
for k in configs.keys():
if k in line and "=" in line:
entry = line.split("=", maxsplit=1)
filtered = "".join((filter(lambda x: x not in ['"'],
entry[1])))
value = filtered.split(" ") # list is space separated
if k == "ksizes":
configs[entry[0]] = [int(v) for v in value]
else:
configs[entry[0]] = value
done[entry[0]] = True
return experiments, configs
def parse_runscript(filepath, config_list):
configs = {}
done = {}
for c in config_list:
configs[c] = None
done[c] = False
with open(filepath, "r") as f:
for line in f:
line = line.strip()
if line == "" or line.startswith("#"):
continue
for k in configs.keys():
if k in line:
entry = line.split("=", maxsplit=1)
filtered = "".join((filter(lambda x: x not in ['"'],
entry[1])))
if k == "trials":
configs[k] = int(filtered)
done[k] = True
if False in done.values():
continue
else:
break
return configs
def report_empty(run):
pass
# print(
# "Warning: No data found; skipping ({}). This is not always an error (see `microbench/supported.inc`)"
# .format(run))
class CSVFile:
"""A wrapper class to read and manipulate data from output produced by make_csv.sh"""
def __init__(self, filepath):
self.filepath = filepath
self.df = pandas.read_csv(filepath,
sep=",",
engine="c",
index_col=False)
def __str__(self):
return str(self.df.columns)
def getdata(self, filter_col, filter_with):
data = self.df.copy() # Make a copy of the data frame to return.
for o, w in zip(filter_col, filter_with):
# Filter the data for the rows matching the column.
data = data[data[o] == w]
return data
# Tries to create a csv file for the given data structure (ds) and number of trials (n).
@staticmethod
def get_or_gen_csv(dirpath, ds, n):
filepath = os.path.join(dirpath, ds + ".csv")
assert os.path.exists(os.path.join("./microbench", "make_csv.sh"))
if not os.path.exists(filepath):
subprocess.call(
"./microbench/make_csv.sh " + dirpath + " " + str(n) + " " +
ds,
shell=True,
)
return filepath