-
Notifications
You must be signed in to change notification settings - Fork 0
/
csvgen.py
157 lines (122 loc) · 4.31 KB
/
csvgen.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
ns = set()
dists = set()
sorts = set()
shufs = set()
mems = set()
with open("result.txt", "r") as f:
lines = f.readlines()
for line in lines:
stripped = line.strip()
splittedPipe = stripped.split("|")
if len(splittedPipe) == 2:
dist = splittedPipe[0].strip()
n = splittedPipe[1].split(",")[0].strip().split(" ")[0].strip()
if dist not in dists:
dists.add(dist)
if n not in ns:
ns.add(n)
continue
splittedColon = stripped.split(":")
if len(splittedColon) == 2:
sortinfo = splittedColon[0].split("(")
sortname = sortinfo[0].strip()
mem = sortinfo[1].replace(")", "").strip()
if sortname not in sorts:
sorts.add(sortname)
if mem not in mems:
mems.add(mem)
continue
shuf = stripped.replace(".", "")
if shuf not in shufs:
shufs.add(shuf)
res = {
sort: {
n: {
shuf: {
mem: {
dist: None
for dist in dists
}
for mem in mems
}
for shuf in shufs
}
for n in ns
}
for sort in sorts
}
currn = None
currd = None
currs = None
for line in lines:
stripped = line.strip()
splittedPipe = stripped.split("|")
if len(splittedPipe) == 2:
currd = splittedPipe[0].strip()
currn = splittedPipe[1].split(",")[0].strip().split(" ")[0].strip()
continue
splittedColon = stripped.split(":")
if len(splittedColon) == 2:
time = splittedColon[1].strip()
sortinfo = splittedColon[0].split("(")
sortname = sortinfo[0].strip()
mem = sortinfo[1].replace(")", "").strip()
res[sortname][currn][currs][mem][currd] = time
continue
currs = stripped.replace(".", "")
# group by shuffle, different tables for each n and each unique amount
for n in ns:
for dist in dists:
with open(f"tables/shufs_{n}_{dist}.csv", "w") as f:
f.write(f"{n}_{dist},")
out = ""
for sort in sorts:
for mem in res[sort][n][next(iter(shufs))]:
if res[sort][n][shuf][mem][dist] is not None:
out += f"{sort} ({mem}),"
f.write(out[:-1] + "\n")
for shuf in shufs:
f.write(shuf + ",")
out = ""
for sort in sorts:
for mem in res[sort][n][shuf]:
if res[sort][n][shuf][mem][dist] is not None:
out += res[sort][n][shuf][mem][dist] + ","
f.write(out[:-1] + "\n")
# group by shuffle, different tables for each n, unique amount and memory
for n in ns:
for dist in dists:
for mem in mems:
with open(f"tables/shufs_{n}_{dist}_{mem}.csv", "w") as f:
f.write(f"{n}_{dist}_{mem},")
out = ""
for sort in sorts:
if res[sort][n][shuf][mem][dist] is not None:
out += f"{sort} ({mem}),"
f.write(out[:-1] + "\n")
for shuf in shufs:
f.write(shuf + ",")
out = ""
for sort in sorts:
if res[sort][n][shuf][mem][dist] is not None:
out += res[sort][n][shuf][mem][dist] + ","
f.write(out[:-1] + "\n")
# group by memory, different tables for each n, unique amount and shuffle
for n in ns:
for dist in dists:
for shuf in shufs:
with open(f"tables/mems_{n}_{dist}_{shuf}.csv", "w") as f:
f.write(f"{n}_{dist}_{shuf},")
out = ""
for sort in sorts:
out += sort + ","
f.write(out[:-1] + "\n")
for mem in res[sort][n][shuf]:
f.write(mem + ",")
out = ""
for sort in sorts:
if res[sort][n][shuf][mem][dist] is not None:
out += res[sort][n][shuf][mem][dist] + ","
else:
out += " ,"
f.write(out[:-1] + "\n")