3 """Plot the performance for different block sizes of one function across
18 return '%d k' % (v//1024)
20 return '%.1f k' % (v/1024)
22 def plot(records, function, alignment=None, scale=1):
23 variants = libplot.unique(records, 'variant', prefer='this')
24 records = [x for x in records if x.function==function]
27 records = [x for x in records if x.src_alignment==alignment[0] and
28 x.dst_alignment==alignment[1]]
30 alignments = libplot.unique(records, ('src_alignment', 'dst_alignment'))
31 if len(alignments) != 1:
33 if libplot.alignments_equal(alignments):
34 aalignment = alignments[0][0]
36 aalignment = "%s:%s" % (alignments[0][0], alignments[0][1])
38 bytes = libplot.unique(records, 'bytes')[0]
40 colours = libplot.make_colours()
43 pylab.figure(1).set_size_inches((6.4*scale, 4.8*scale))
47 # The harness fills out to 16k. Anything past that is an
53 for variant in variants:
54 matches = [x for x in records if x.variant==variant and x.bytes <= top]
55 matches.sort(key=lambda x: x.bytes)
57 X = sorted(list(set([x.bytes for x in matches])))
61 vals = [x.bytes*x.loops/x.elapsed/(1024*1024) for x in matches if x.bytes == xbytes]
63 mean = sum(vals)/len(vals)
67 err1 = max(vals) - mean
69 err2 = min(vals) - mean
71 Yerr[0].append(abs(err2))
77 colour = colours.next()
80 pylab.plot(X, Y, c=colour)
82 pylab.errorbar(X, Y, yerr=Yerr, c=colour, label=variant, fmt='o')
84 pylab.scatter(X, Y, c=colour, label=variant, edgecolors='none')
86 pylab.legend(loc='upper left', ncol=3, prop={'size': 'small'})
88 pylab.title('%(function)s of %(aalignment)s byte aligned blocks' % locals())
89 pylab.xlabel('Size (B)')
90 pylab.ylabel('Rate (MB/s)')
92 # Figure out how high the range goes
95 power = int(round(math.log(max(all_x)) / math.log(2)))
99 pylab.axes().set_xticks([2**x for x in range(0, power+1)])
100 pylab.axes().set_xticklabels([pretty_kb(2**x) for x in range(0, power+1)])
102 pylab.ylim(0, pylab.ylim()[1])
106 records = libplot.parse()
108 functions = libplot.unique(records, 'function')
109 alignments = libplot.unique(records, ('src_alignment', 'dst_alignment'))
111 for function in functions:
112 for alignment in alignments:
113 for scale in [1, 2.5]:
114 if plot(records, function, alignment, scale):
115 pylab.savefig('sizes-%s-%02d-%02d-%.1f.png' % (function, alignment[0], alignment[1], scale), dpi=72)
119 if __name__ == '__main__':