29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
1 |
#!/usr/bin/env python
|
2 |
||
3 |
"""Plot the performance for different block sizes of one function across
|
|
4 |
variants.
|
|
5 |
"""
|
|
6 |
||
7 |
import libplot |
|
8 |
||
9 |
import pylab |
|
10 |
import pdb |
|
49
by Michael Hope
Benchmark more sizes and alignments. Make the figures bigger to make the text smaller. Put the 'this' results first. |
11 |
import math |
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
12 |
|
44
by Michael Hope
Various plotting updates. |
13 |
def pretty_kb(v): |
14 |
if v < 1024: |
|
15 |
return '%d' % v |
|
16 |
else: |
|
17 |
if v % 1024 == 0: |
|
18 |
return '%d k' % (v//1024) |
|
19 |
else: |
|
20 |
return '%.1f k' % (v/1024) |
|
21 |
||
80
by Michael Hope
Generate a tumbnail and full size for the size plots. Tweak the colours to have more and make the first a Linaro purple. |
22 |
def plot(records, function, alignment=None, scale=1): |
44
by Michael Hope
Various plotting updates. |
23 |
variants = libplot.unique(records, 'variant', prefer='this') |
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
24 |
records = [x for x in records if x.function==function] |
25 |
||
33
by Michael Hope
Various updates to the benchmark plotting scripts. |
26 |
if alignment != None: |
27 |
records = [x for x in records if x.alignment==alignment] |
|
28 |
||
29 |
alignments = libplot.unique(records, 'alignment') |
|
30 |
assert len(alignments) == 1 |
|
31 |
aalignment = alignments[0] |
|
32 |
||
33 |
bytes = libplot.unique(records, 'bytes')[0] |
|
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
34 |
|
80
by Michael Hope
Generate a tumbnail and full size for the size plots. Tweak the colours to have more and make the first a Linaro purple. |
35 |
colours = libplot.make_colours() |
30
by Michael Hope
Added more ranges. changed everything to MB/s. Account for the loop overhead. |
36 |
all_x = [] |
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
37 |
|
80
by Michael Hope
Generate a tumbnail and full size for the size plots. Tweak the colours to have more and make the first a Linaro purple. |
38 |
pylab.figure(1).set_size_inches((6.4*scale, 4.8*scale)) |
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
39 |
pylab.clf() |
40 |
||
49
by Michael Hope
Benchmark more sizes and alignments. Make the figures bigger to make the text smaller. Put the 'this' results first. |
41 |
if 'str' in function: |
42 |
# The harness fills out to 16k. Anything past that is an
|
|
43 |
# early match
|
|
44 |
top = 16384 |
|
45 |
else: |
|
46 |
top = 2**31 |
|
47 |
||
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
48 |
for variant in variants: |
49
by Michael Hope
Benchmark more sizes and alignments. Make the figures bigger to make the text smaller. Put the 'this' results first. |
49 |
matches = [x for x in records if x.variant==variant and x.bytes <= top] |
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
50 |
matches.sort(key=lambda x: x.bytes) |
51 |
||
52 |
X = [x.bytes for x in matches] |
|
53 |
Y = [x.bytes*x.loops/x.elapsed/(1024*1024) for x in matches] |
|
54 |
||
30
by Michael Hope
Added more ranges. changed everything to MB/s. Account for the loop overhead. |
55 |
all_x.extend(X) |
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
56 |
colour = colours.next() |
57 |
||
58 |
if X: |
|
59 |
pylab.plot(X, Y, c=colour) |
|
49
by Michael Hope
Benchmark more sizes and alignments. Make the figures bigger to make the text smaller. Put the 'this' results first. |
60 |
pylab.scatter(X, Y, c=colour, label=variant, edgecolors='none') |
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
61 |
|
80
by Michael Hope
Generate a tumbnail and full size for the size plots. Tweak the colours to have more and make the first a Linaro purple. |
62 |
pylab.legend(loc='upper left', ncol=3, prop={'size': 'small'}) |
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
63 |
pylab.grid() |
44
by Michael Hope
Various plotting updates. |
64 |
pylab.title('%(function)s of %(aalignment)s byte aligned blocks' % locals()) |
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
65 |
pylab.xlabel('Size (B)') |
66 |
pylab.ylabel('Rate (MB/s)') |
|
49
by Michael Hope
Benchmark more sizes and alignments. Make the figures bigger to make the text smaller. Put the 'this' results first. |
67 |
|
68 |
# Figure out how high the range goes
|
|
69 |
top = max(all_x) |
|
70 |
||
71 |
power = int(round(math.log(max(all_x)) / math.log(2))) |
|
72 |
||
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
73 |
pylab.semilogx() |
49
by Michael Hope
Benchmark more sizes and alignments. Make the figures bigger to make the text smaller. Put the 'this' results first. |
74 |
|
75 |
pylab.axes().set_xticks([2**x for x in range(0, power+1)]) |
|
76 |
pylab.axes().set_xticklabels([pretty_kb(2**x) for x in range(0, power+1)]) |
|
77 |
pylab.xlim(0, top) |
|
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
78 |
pylab.ylim(0, pylab.ylim()[1]) |
79 |
||
80 |
def main(): |
|
81 |
records = libplot.parse() |
|
82 |
||
83 |
functions = libplot.unique(records, 'function') |
|
44
by Michael Hope
Various plotting updates. |
84 |
alignments = libplot.unique(records, 'alignment') |
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
85 |
|
86 |
for function in functions: |
|
44
by Michael Hope
Various plotting updates. |
87 |
for alignment in alignments: |
80
by Michael Hope
Generate a tumbnail and full size for the size plots. Tweak the colours to have more and make the first a Linaro purple. |
88 |
for scale in [1, 2.5]: |
89 |
plot(records, function, alignment, scale) |
|
90 |
pylab.savefig('sizes-%s-%02d-%.1f.png' % (function, alignment, scale), dpi=72) |
|
44
by Michael Hope
Various plotting updates. |
91 |
|
92 |
pylab.show() |
|
29
by Michael Hope
Added some scripts to run the benchmarks and to plot the results. |
93 |
|
94 |
if __name__ == '__main__': |
|
95 |
main() |