-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathait-plot-netperf-udp_stream
executable file
·222 lines (177 loc) · 6.82 KB
/
ait-plot-netperf-udp_stream
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
#! /usr/bin/python
# -*- python -*-
# -*- coding: utf-8 -*-
try:
from sqlite3 import connect as sqlite3_connect
except:
from sqlite import connect as sqlite3_connect
from dbstats import dbstats
import os, rit, time
def get_results(db, report):
db.cursor.execute('''
select msg_size, remote_throughput
from netperf_udp_stream
where report = %d
order by msg_size
''' % report)
return db.cursor.fetchall()
inches = 0.00666667
def plot_metric_report(ax, info, seq):
xtickfontsize = 8
ytickfontsize = 8
ax.grid(False)
ax.plot(info["msg_sizes"][:-1], info["remote_throughput"][:-1], info["color"])
ylabel = "%s, rep=%d" % (info["kernel_release"], info["report"])
ax.annotate(ylabel, xy = (85, 360 - 11 * seq),
xycoords='figure points',
fontname='Bitstream Vera Sans',
fontsize=8, color=info["color"])
for label in ax.get_xticklabels():
label.set(fontsize = xtickfontsize)
for label in ax.get_yticklabels():
label.set(fontsize = ytickfontsize)
def plot_metric(ref, others):
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
from matplotlib.ticker import FuncFormatter
green_font = { 'fontname' : 'Bitstream Vera Sans',
'color' : 'g',
'fontweight' : 'bold',
'fontsize' : 10 }
width = 1250 * inches
height = 880 * inches
fig = Figure(figsize = (width, height))
canvas = FigureCanvas(fig)
# Reference results
ax1 = fig.add_subplot(111)
caption = "Remote Throughput"
ax1.set_title("%d %s samples" % (len(others[0]["remote_throughput"]), caption), green_font)
ax1.set_xlabel("Message Size", green_font)
ax1.set_ylabel(caption, green_font)
plot_metric_report(ax1, ref, 0)
seq = 1;
for other in others:
ax2 = fig.add_axes(ax1.get_position(), sharex = ax1, sharey = ax1, frameon = False)
plot_metric_report(ax2, other, seq)
seq += 1
del ax2
list_others = ",".join([ str(o["report"]) for o in others ])
canvas.print_figure("%d_%s.png" % (ref["report"], list_others))
del fig, canvas, ax1
xlabels = []
colors = ( "b", "r", "g", "c", "m", "y", "k" )
color_index = 0
html_colors = { "b" : "blue",
"r" : "red",
"g" : "green",
"c" : "cyan",
"m" : "magenta",
"y" : "yellow",
"k" : "brown"
}
def get_report_info(db, report):
global color_index
results = get_results(db, report)
info = {}
info["report"] = report
info["ctime"] = db.get_ctime_for_report(report)
info["kernel_release"] = db.get_kernel_release_for_report(report)
info["libc"] = db.get_libc_release_for_report(report)
info["max_msg_size"] = db.get_max_msg_size_for_report(report)
info["msg_sizes"] = [ i[0] for i in results ]
info["remote_throughput"] = [ i[1] for i in results ]
info["color"] = colors[color_index]
color_index += 1
del results
return info
def get_common_columns(results, columns):
common_columns = []
for column_index in range(len(columns)):
if len(list(set([result["system_tunings"][column_index] for result in results]))) == 1:
common_columns.append(column_index)
return common_columns
def create_html(db, ref, others, field_exclude_list):
list_others = ",".join([ str(o["report"]) for o in others ])
prefix="%d_%s" % (ref["report"], list_others)
f = file("%d_%s.html" % (ref["report"], list_others), "w")
f.write('''
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Reports: %s</title>
</head>
<body>
<img src="%s.png">
''' % ([ref["report"]] + [o["report"] for o in others], prefix))
ref["system_tunings"] = db.get_system_tunings_for_report(ref["report"])
for other in others:
other["system_tunings"] = db.get_system_tunings_for_report(other["report"])
columns = [column[0] for column in db.cursor.description]
common_columns = get_common_columns([ ref, ] + others, columns)
lock_stat_index = columns.index("lock_stat")
if lock_stat_index in common_columns:
common_columns.remove(lock_stat_index)
f.write('<h1>Specific Tunings:</h0>\n<table border=1 style="background-color: #8aa;400px; border: thin solid black; font-family: sans-serif; font-size: 10px;">\n<tr>')
f.write("<th>date</th><th>report</th><th>max<br>packet<br>rate</th>")
for column in range(len(columns)):
if column not in common_columns and columns[column] not in field_exclude_list:
f.write("<th>%s</th>" % columns[column].replace("_", "<br>"))
color_index = 0
f.write('</tr>\n<tr>')
f.write('<td>%s</td>' % time.ctime(ref["ctime"]))
f.write('<td style="background-color: %s">%s</td>' % (html_colors[colors[color_index]], ref["report"]))
f.write('<td>%d</td>' % ref["max_msg_size"])
color_index += 1
for field in range(len(columns)):
if field not in common_columns and columns[field] not in field_exclude_list:
if columns[field] == "lock_stat" and \
os.access("lock_stat/%d.txt", os.F_OK):
f.write("<td><a href=lock_stat/%s.txt>%s</a></td>" % (ref["report"], ref["system_tunings"][field]))
else:
f.write("<td>%s</td>" % ref["system_tunings"][field])
for other in others:
f.write('</tr>\n<tr>')
f.write('<td>%s</td>' % time.ctime(other["ctime"]))
f.write('<td style="background-color: %s">%s</td>' % (html_colors[colors[color_index]], other["report"]))
f.write('<td>%d</td>' % other["max_msg_size"])
color_index += 1
for field in range(len(columns)):
if field not in common_columns and columns[field] not in field_exclude_list:
if columns[field] == "lock_stat" and \
os.access("lock_stat/%d.txt" % other["report"], os.F_OK):
f.write("<td><a href=lock_stat/%s.txt>%s</a></td>" % (other["report"], other["system_tunings"][field]))
else:
f.write("<td>%s</td>" % other["system_tunings"][field])
f.write('</tr>\n</table>\n')
f.write('<h1>Common Tunings:</h1>\n<table border=1 style="background-color: #8aa;400px; border: thin solid black; font-family: sans-serif; font-size: 10px;">\n<tr>')
for column in common_columns:
if columns[column] not in field_exclude_list:
f.write("<th>%s</th>" % columns[column].replace("_", "<br>"))
f.write('</tr>\n<tr>')
for column in common_columns:
if columns[column] not in field_exclude_list:
f.write("<td>%s</td>" % ref["system_tunings"][column])
f.write("</tr>\n</table>\n")
f.write("</tr>\n</table>\n</body>\n</html>\n")
f.close()
def plot_metric_graphs(db, ref_report, reports, field_exclude_list):
global color_index
color_index = 0
ref = get_report_info(db, ref_report)
others = []
for other in reports.split(","):
others.append(get_report_info(db, int(other)))
plot_metric(ref, others)
create_html(db, ref, others, field_exclude_list)
if __name__ == '__main__':
import sys
appname = sys.argv[1]
ref_report = int(sys.argv[2])
reports = sys.argv[3]
if len(sys.argv) > 4:
field_exclude_list = sys.argv[4].split(",")
else:
field_exclude_list = []
db = dbstats(appname)
plot_metric_graphs(db, ref_report, reports, field_exclude_list)