-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplot_results.py
More file actions
executable file
·141 lines (115 loc) · 5.24 KB
/
plot_results.py
File metadata and controls
executable file
·141 lines (115 loc) · 5.24 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
#!/usr/bin/env python3
import sys
import pickle
import matplotlib.pyplot as plt
line_styles = {
"v3_10":":",
"v3_12":"-",
"v3_14":":",
"v3_15":"-",
"v3_16":"-",
"v3_20":".",
"v3_24":"-.",
"v3_34":"--",
"v3_35":"-.",
"v3_36":"-"
}
def average(l):
return sum(l) / len(l)
def plot_figure(data, x_axis_label, figname):
# PLOT RESULTS
fontsize = 20
f, ax1 = plt.subplots(1, 1, sharey=True, figsize=(14, 7))
ax2 = ax1.twinx()
plt.grid(axis='y')
lns_handles = []
for version in data.keys():
line_style = line_styles[version]
average_times = [average(data[version][x][0]) for x in data[version].keys()]
lns1 = ax1.plot(list(data[version].keys()), average_times, 'r' + line_style, linewidth=4,
label="Simulation Time " + version)
for x in data[version].keys():
to_plot = [min(data[version][x][0]),
max(data[version][x][0])]
for time in to_plot:
ax1.plot([x], [time], 'r', linewidth=3)
ax1.plot([x, x], [to_plot[0], to_plot[1]], 'r', linewidth=3)
average_footprints = [average(data[version][x][1]) for x in data[version].keys()]
lns2 = ax2.plot(sorted(list(data[version].keys())), average_footprints, 'b' + line_style, linewidth=4,
label="Maximum RSS " + version)
for x in list(data[version].keys()):
to_plot = [min(data[version][x][1]), max(data[version][x][1])]
for footprint in to_plot:
ax2.plot([x], [footprint], 'b', linewidth=3)
ax2.plot([x, x], [to_plot[0], to_plot[1]], 'b', linewidth=3)
lns_handles.append(lns1)
lns_handles.append(lns2)
ax1.set_xlim([min(data[versions[0]].keys()), max(data[versions[0]].keys())])
ax1.set_xlabel(x_axis_label, fontsize=fontsize + 3)
ax1.set_ylabel("Time (sec)", fontsize=fontsize + 3)
ax2.set_ylabel("Memory Footprint (MB)", fontsize=fontsize + 3)
ax1.tick_params(axis='x', labelsize=fontsize + 3)
ax1.tick_params(axis='y', labelsize=fontsize + 3)
ax2.tick_params(axis='y', labelsize=fontsize + 3)
# lns = lns_handles[0] + lns_handles[1] + lns_handles[2] + lns_handles[3] + lns_handles[4] + lns_handles[5]
lns = lns_handles[0] + lns_handles[1]
for i in range(1, len(data.keys())):
print(i)
lns += lns_handles[i * 2] + lns_handles[i * 2 + 1]
labs = [l.get_label() for l in lns]
ax2.legend(lns, labs, loc=6, fontsize=fontsize + 3)
f.tight_layout()
plt.savefig(figname)
print("Figure saved to: " + figname)
print("Statistics:")
version1 = versions[0]
version2 = versions[1]
time_ratios = []
rss_ratios = []
for x in list(data[version1].keys()):
time_ratio = average(data[version2][x][0]) / average(
data[version1][x][0])
rss_ratio = average(data[version2][x][1]) / average(
data[version1][x][1])
time_ratios.append(time_ratio)
rss_ratios.append(rss_ratio)
print(f"Time ratios: min={min(time_ratios)} max={max(time_ratios)} ave={average(time_ratios)}")
print(f"RSS ratios: min={min(rss_ratios)} max={max(rss_ratios)} ave={average(rss_ratios)}")
if __name__ == "__main__":
try:
pickle_file_name = sys.argv[1]
output_pdf_file = sys.argv[2]
except Exception:
sys.stderr.write(f"Usage: {sys.argv[0]} <input pickle file name with results> <output PDF file>\n")
sys.exit(1)
with open(pickle_file_name, 'rb') as file:
results = pickle.load(file)
# results[num_workunits][num_hosts][num_cores_per_host][version] = [times, mems]
print(results)
num_workunits_values = sorted(list(results.keys()))
num_hosts_values = sorted(list(results[num_workunits_values[0]].keys()))
num_num_cores_per_host_values = sorted(list(results[num_workunits_values[0]][num_hosts_values[0]].keys()))
versions = sorted(list(results[num_workunits_values[0]][num_hosts_values[0]][num_num_cores_per_host_values[0]].keys()))
if len(num_workunits_values) != 1:
data = {}
for version in versions:
data[version] = {}
for x in results:
data[version][x] = results[x][num_hosts_values[0]][num_num_cores_per_host_values[0]][version]
plot_figure(data, "# of workunits", output_pdf_file)
elif len(num_hosts_values) != 1:
data = {}
for version in versions:
data[version] = {}
for x in results[num_workunits_values[0]]:
data[version][x] = results[num_workunits_values[0]][x][num_num_cores_per_host_values[0]][version]
plot_figure(data, f"# of hosts ({num_num_cores_per_host_values[0]} cores / host)", output_pdf_file)
elif len(num_num_cores_per_host_values) != 1:
data = {}
for version in versions:
data[version] = {}
for x in results[num_workunits_values[0]][num_hosts_values[0]]:
data[version][x] = results[num_workunits_values[0]][num_hosts_values[0]][x][version]
plot_figure(data, f"# of cores / host ({num_hosts_values[0]} hosts)", output_pdf_file)
else:
raise "Something went wrong with dimensions..."