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
|
#!/usr/bin/env python
"""Plot the performance for different block sizes of one function across
variants.
"""
import libplot
import pylab
import pdb
import math
def pretty_kb(v):
if v < 1024:
return '%d' % v
else:
if v % 1024 == 0:
return '%d k' % (v//1024)
else:
return '%.1f k' % (v/1024)
def plot(records, function, alignment=None, scale=1):
variants = libplot.unique(records, 'variant', prefer='this')
records = [x for x in records if x.function==function]
if alignment != None:
records = [x for x in records if x.alignment==alignment]
alignments = libplot.unique(records, 'alignment')
assert len(alignments) == 1
aalignment = alignments[0]
bytes = libplot.unique(records, 'bytes')[0]
colours = libplot.make_colours()
all_x = []
pylab.figure(1).set_size_inches((6.4*scale, 4.8*scale))
pylab.clf()
if 'str' in function:
# The harness fills out to 16k. Anything past that is an
# early match
top = 16384
else:
top = 2**31
for variant in variants:
matches = [x for x in records if x.variant==variant and x.bytes <= top]
matches.sort(key=lambda x: x.bytes)
X = [x.bytes for x in matches]
Y = [x.bytes*x.loops/x.elapsed/(1024*1024) for x in matches]
all_x.extend(X)
colour = colours.next()
if X:
pylab.plot(X, Y, c=colour)
pylab.scatter(X, Y, c=colour, label=variant, edgecolors='none')
pylab.legend(loc='upper left', ncol=3, prop={'size': 'small'})
pylab.grid()
pylab.title('%(function)s of %(aalignment)s byte aligned blocks' % locals())
pylab.xlabel('Size (B)')
pylab.ylabel('Rate (MB/s)')
# Figure out how high the range goes
top = max(all_x)
power = int(round(math.log(max(all_x)) / math.log(2)))
pylab.semilogx()
pylab.axes().set_xticks([2**x for x in range(0, power+1)])
pylab.axes().set_xticklabels([pretty_kb(2**x) for x in range(0, power+1)])
pylab.xlim(0, top)
pylab.ylim(0, pylab.ylim()[1])
def main():
records = libplot.parse()
functions = libplot.unique(records, 'function')
alignments = libplot.unique(records, 'alignment')
for function in functions:
for alignment in alignments:
for scale in [1, 2.5]:
plot(records, function, alignment, scale)
pylab.savefig('sizes-%s-%02d-%.1f.png' % (function, alignment, scale), dpi=72)
pylab.show()
if __name__ == '__main__':
main()
|