-
Notifications
You must be signed in to change notification settings - Fork 4
/
generate-results.py
167 lines (126 loc) · 5.15 KB
/
generate-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
import datetime
from datetime import timedelta, timezone
from pathlib import Path
import numpy
import pandas
import pytz
import seaborn as sns
from jinja2 import Template
from pint import UnitRegistry
ureg = UnitRegistry()
x = ureg.Quantity(1, "bytes")
utctzinfo = timezone(timedelta(hours=0))
timeformat = "%Y-%m-%dT%H:%M:%S"
def gen_plots():
shape_index_mapping = {
"(512, 128, 1)": numpy.prod((512, 128, 1)) * 4 * ureg.bytes,
"(1024, 512, 1)": numpy.prod((1024, 512, 1)) * 4 * ureg.bytes,
"(2048, 1024, 1)": numpy.prod((2048, 1024, 1)) * 4 * ureg.bytes,
"(512, 512, 32)": numpy.prod((512, 512, 32)) * 4 * ureg.bytes,
"(1024, 1024, 256)": numpy.prod((1024, 1024, 256)) * 4 * ureg.bytes,
}
results_unique = pandas.read_csv("results-unique.csv", sep="\t")
results_unique["shape_ind"] = results_unique["shape"].map(shape_index_mapping)
results_unique["shape_ind_r"] = results_unique["shape_ind"].apply(lambda x: format(x.to_compact(), "~.0f"))
results_unique["memory_ref"] = results_unique["shape_ind"].apply(lambda x: x.magnitude)
results_unique["mem_max_norm"] = results_unique["mem_max"] / results_unique["memory_ref"]
p = sns.lineplot(x="shape_ind_r", y="t", hue="method", data=results_unique)
p.set(yscale="log")
fig = p.get_figure()
fig.savefig("unique-runningtime.png")
p.clear()
p = sns.lineplot(x="shape_ind_r", y="mem_max_norm", hue="method", data=results_unique)
p.set(yscale="log")
fig = p.get_figure()
fig.savefig("unique-max-memory.png")
p.clear()
# normalize data
# method shape t py_version npy_version pandas_version vigra_version host platform mem_min mem_max
np_unique = results_unique[results_unique["method"] == "numpy.unique(data)"]
normalization_factors = {}
for _, row in np_unique.iterrows():
key = (
row["host"],
row["platform"],
row["shape"],
row["py_version"],
row["npy_version"],
row["pandas_version"],
row["vigra_version"],
)
normalization_factors[key] = row["t"]
def normalize(row):
key = (
row["host"],
row["platform"],
row["shape"],
row["py_version"],
row["npy_version"],
row["pandas_version"],
row["vigra_version"],
)
return row["t"] / normalization_factors[key]
results_unique["normalized_t"] = results_unique.apply(normalize, axis=1)
p = sns.lineplot(x="shape_ind_r", y="normalized_t", hue="method", data=results_unique)
p.set(yscale="log")
fig = p.get_figure()
fig.savefig("unique-runningtime-normalized.png")
p.clear()
results_bincount = pandas.read_csv("results-bincount.csv", sep="\t")
results_bincount["shape_ind"] = results_bincount["shape"].map(shape_index_mapping)
results_bincount["shape_ind_r"] = results_bincount["shape_ind"].apply(lambda x: format(x.to_compact(), "~.0f"))
results_bincount["memory_ref"] = results_bincount["shape_ind"].apply(lambda x: x.magnitude)
results_bincount["mem_max_norm"] = results_bincount["mem_max"] / results_bincount["memory_ref"]
p = sns.lineplot(x="shape_ind_r", y="t", hue="method", data=results_bincount)
p.set(yscale="log")
fig = p.get_figure()
fig.savefig("bincount-runningtime.png")
p.clear()
p = sns.lineplot(x="shape_ind_r", y="mem_max_norm", hue="method", data=results_bincount)
p.set(yscale="log")
fig = p.get_figure()
fig.savefig("bincount-max-memory.png")
p.clear()
# normalize data
# method shape t py_version npy_version pandas_version vigra_version host platform mem_min mem_max
np_bincount = results_bincount[results_bincount["method"] == "numpy.bincount(data.reshape(-1))"]
normalization_factors = {}
for _, row in np_bincount.iterrows():
key = (
row["host"],
row["platform"],
row["shape"],
row["py_version"],
row["npy_version"],
row["pandas_version"],
row["vigra_version"],
)
normalization_factors[key] = row["t"]
def normalize(row):
key = (
row["host"],
row["platform"],
row["shape"],
row["py_version"],
row["npy_version"],
row["pandas_version"],
row["vigra_version"],
)
return row["t"] / normalization_factors[key]
results_bincount["normalized_t"] = results_bincount.apply(normalize, axis=1)
p = sns.lineplot(x="shape_ind_r", y="normalized_t", hue="method", data=results_bincount)
p.set(yscale="log")
fig = p.get_figure()
fig.savefig("bincount-runningtime-normalized.png")
p.clear()
def main():
template = Template(Path("Results.md.in").read_text())
gen_plots()
n_hosts = len(pandas.read_csv("results-unique.csv", sep="\t")["host"].unique())
tz = pytz.timezone("Europe/Berlin")
now = datetime.datetime.now(tz)
# render
rendered = template.render(now=now.strftime(timeformat), n_hosts=n_hosts)
Path("Results.md").write_text(rendered)
if __name__ == "__main__":
main()