-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate_tables.py
148 lines (133 loc) · 4.16 KB
/
generate_tables.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
import sys
from pytablewriter import MarkdownTableWriter
entries = []
f = open("last_simd.txt", "r")
for line in f:
tokens = line[:-1].split(" ")
sz = int(tokens[3])
t_dec = float(tokens[2])
t = float(tokens[1])
name = tokens[0].split("/")
name = name[len(name)-1]
tokens = name.split(".")
name = tokens[0] + "." + tokens[1]
l = len(tokens)
precision = int(tokens[l-1][3:-1])
level = int(tokens[l-2])
enc = tokens[l-3]
comp = tokens[l-4].lower()
if enc == "no_enc":
enc = "plain"
elif enc == "dict":
enc = "dictionary"
elif enc == "fp":
enc = "split"
elif enc == "fp_xor":
enc = "split+xor"
elif enc == "fp_comp":
enc = "split component"
elif enc == "fp_rle":
enc = "split+rle"
else:
print(enc)
assert(False)
entries.append((name, enc, comp, level, precision, sz, t))
uncompressed_size = {}
h = ["Configuration \\ Test"]
table1 = []
table2 = []
row = ["no compression"]
row2 = ["no compression"]
for u in entries:
if u[1] == "plain" and u[2] == "uncompressed":
print(u)
h.append(u[0])
row.append("1.00")
uncompressed_size[u[0]] = u[5]
row2.append((u[5] / (1024 * 1024)) / u[6])
table1.append(row)
table2.append(row2)
comb = [("gzip", "plain", "gzip"), ("dictionary + gzip", "dictionary", "gzip"),
("byte_stream_split + gzip", "split", "gzip"), ("byte_stream_split_xor + gzip", "split+xor", "gzip"),
("byte_stream_split_component + gzip", "split component", "gzip"),
("byte_stream_split_rle + gzip", "split+rle", "gzip"),
("zstd", "plain", "zstd"), ("dictionary + zstd", "dictionary", "zstd"),
("byte_stream_split + zstd", "split", "zstd"), ("byte_stream_split_xor + zstd", "split+xor", "zstd"),
("byte_stream_split_component + zstd", "split component", "zstd"),
("byte_stream_split_rle + zstd", "split+rle", "zstd")]
comb = [("byte_stream_split + zstd", "split", "zstd")]
best = {}
best2 = {}
for u in uncompressed_size:
best[u] = -1.0
best2[u] = -1.0
for c in comb:
i = 0
for u in entries:
if u[1] == c[1] and u[2] == c[2] and u[3] == -1:
assert(h[1+i] == u[0]) # check that order is preserved
ratio = uncompressed_size[u[0]] / u[5]
if ratio > best[u[0]]:
best[u[0]] = ratio
speed = (u[5] / (1024 * 1024)) / u[6]
if speed > best2[u[0]]:
best2[u[0]] = speed
i+=1
for c in comb:
row = [c[0]]
row2 = [c[0]]
i = 0
for u in entries:
if u[1] == c[1] and u[2] == c[2] and u[3] == -1:
assert(h[1+i] == u[0]) # check that order is preserved
ratio = uncompressed_size[u[0]] / u[5]
s = "{0:.2f}".format(ratio)
if ratio == best[u[0]]:
s = "***" + s + "***"
row.append(s)
speed = (u[5] / (1024 * 1024)) / u[6]
s = "{0:.2f}".format(speed)
if speed == best2[u[0]]:
s = "***" + s + "***"
row2.append(s)
i += 1
table1.append(row)
table2.append(row2)
writer = MarkdownTableWriter()
writer.table_name = "Compression ratio"
writer.headers = h
writer.value_matrix = table1
writer.write_table()
print()
writer = MarkdownTableWriter()
writer.table_name = "Compression speed"
writer.headers = h
writer.value_matrix = table2
writer.write_table()
"""
h = ["Test", "Level", "zstd", "dictionary + zstd", "byte_stream_split + zstd"]
mp = {}
for u in uncompressed_size:
for v in ["plain", "dictionary", "split":
mp[(u,v)] = []
for u in entries:
for i in range(1, 13, 3):
if u[1] in ["split", "dictionary", "plain"] and u[2] == "zstd" and u[3] == i:
mp[(u[0], u[1])].append((i, uncompressed_size[u[0]] / u[5]))
table = []
for u in mp:
res = mp[u]
i = 0
for v in res:
if i == 0:
table.append([u, v[0], v[1]])
else:
table.append(["", v[0], v[1]])
i += 1
print()
writer = MarkdownTableWriter()
writer.table_name = "Compression levels"
writer.headers = h
writer.value_matrix = table
writer.write_table()
"""