1
"""Plot the results for each test. Spits out a set of images into the
11
Record = collections.namedtuple('Record', 'variant test size loops src_alignment dst_alignment run_id rawtime comment time bytes rate')
13
def unique(rows, name):
14
"""Takes a list of values, pulls out the named field, and returns
15
a list of the unique values of this field.
17
return sorted(set(getattr(x, name) for x in rows))
20
"""Convert a string into a better type.
39
rows = [x.strip().split(':') for x in fileinput.input()]
40
# Automatically turn numbers into the base type
41
rows = [[to_float(y) for y in x] for x in rows]
43
# Scan once to calculate the overhead
44
r = [Record(*(x + [0, 0, 0])) for x in rows]
45
bounces = pylab.array([(x.loops, x.rawtime) for x in r if x.test == 'bounce'])
46
fit = pylab.polyfit(bounces[:,0], bounces[:,1], 1)
51
# Make a dummy record so we can use the names
52
r1 = Record(*(row + [0, 0, 0]))
54
bytes = r1.size * r1.loops
55
# Calculate the bounce time
56
delta = pylab.polyval(fit, [r1.loops])
57
time = r1.rawtime - delta
60
records.append(Record(*(row + [time, bytes, rate])))
64
def plot(records, field, scale, ylabel):
65
variants = unique(records, 'variant')
66
tests = unique(records, 'test')
68
# A little hack. We want the 'all' record to be drawn last so
69
# that it's obvious on the graph. Assume that no tests come
70
# before it alphabetically
74
for variant in variants:
75
v = [x for x in records if x.test==test and x.variant==variant]
76
v.sort(key=lambda x: x.size)
77
V = pylab.array([(x.size, getattr(x, field)) for x in v])
79
# Ensure our results appear
80
order = 1 if variant == 'this' else 0
83
# A little hack. We want the 'all' to be obvious on
86
pylab.scatter(V[:,0], V[:,1]/scale, label=variant)
87
pylab.plot(V[:,0], V[:,1]/scale)
89
pylab.plot(V[:,0], V[:,1]/scale, label=variant, zorder=order)
92
# michaelh1 likes to run this script while the test is
93
# still running which can lead to bad data
94
print ex, 'on %s of %s' % (variant, test)
96
pylab.legend(loc='lower right', ncol=2, prop={'size': 'small'})
97
pylab.xlabel('Block size (B)')
99
pylab.title('%s %s' % (test, field))
102
pylab.savefig('%s-%s.png' % (test, field), dpi=100)
103
pylab.semilogx(basex=2)
104
pylab.savefig('%s-%s-semilog.png' % (test, field), dpi=100)
114
plot(records, 'rate', 1024**2, 'Rate (MB/s)')
115
plot(records, 'time', 1, 'Total time (s)')
117
if __name__ == '__main__':