~linaro-toolchain-dev/cortex-strings/trunk

33 by Michael Hope
Various updates to the benchmark plotting scripts.
1
#!/usr/bin/env python
2
3
"""Plot the performance of different variants of one routine versus alignment.
4
"""
5
6
import libplot
7
8
import pylab
9
10
11
def plot(records, bytes, function):
12
    records = [x for x in records if x.bytes==bytes and x.function==function]
13
49 by Michael Hope
Benchmark more sizes and alignments. Make the figures bigger to make the text smaller. Put the 'this' results first.
14
    variants = libplot.unique(records, 'variant', prefer='this')
113 by Will Newton
Allow aligning source and destination buffers separately.
15
    alignments = libplot.unique(records, ('src_alignment', 'dst_alignment'))
33 by Michael Hope
Various updates to the benchmark plotting scripts.
16
17
    X = pylab.arange(len(alignments))
49 by Michael Hope
Benchmark more sizes and alignments. Make the figures bigger to make the text smaller. Put the 'this' results first.
18
    width = 1.0/(len(variants)+1)
33 by Michael Hope
Various updates to the benchmark plotting scripts.
19
20
    colours = iter('bgrcmyk')
21
49 by Michael Hope
Benchmark more sizes and alignments. Make the figures bigger to make the text smaller. Put the 'this' results first.
22
    pylab.figure(1).set_size_inches((16, 12))
33 by Michael Hope
Various updates to the benchmark plotting scripts.
23
    pylab.clf()
24
25
    for i, variant in enumerate(variants):
26
        heights = []
27
28
        for alignment in alignments:
113 by Will Newton
Allow aligning source and destination buffers separately.
29
            matches = [x for x in records if x.variant==variant and x.src_alignment==alignment[0] and x.dst_alignment==alignment[1]]
33 by Michael Hope
Various updates to the benchmark plotting scripts.
30
31
            if matches:
115 by Will Newton
Support multiple runs of each benchmark.
32
                vals = [match.bytes*match.loops/match.elapsed/(1024*1024) for
33
                        match in matches]
34
                mean = sum(vals)/len(vals)
35
                heights.append(mean)
33 by Michael Hope
Various updates to the benchmark plotting scripts.
36
            else:
37
                heights.append(0)
38
39
        pylab.bar(X+i*width, heights, width, color=colours.next(), label=variant)
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
33 by Michael Hope
Various updates to the benchmark plotting scripts.
42
    axes = pylab.axes()
113 by Will Newton
Allow aligning source and destination buffers separately.
43
    if libplot.alignments_equal(alignments):
44
        alignment_labels = ["%s" % x[0] for x in alignments]
45
    else:
46
        alignment_labels = ["%s:%s" % (x[0], x[1]) for x in alignments]
47
    axes.set_xticklabels(alignment_labels)
33 by Michael Hope
Various updates to the benchmark plotting scripts.
48
    axes.set_xticks(X + 0.5)
49
50
    pylab.title('Performance of different variants of %(function)s for %(bytes)d byte blocks' % locals())
51
    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.
52
    pylab.legend(loc='upper left', ncol=3)
33 by Michael Hope
Various updates to the benchmark plotting scripts.
53
    pylab.grid()
49 by Michael Hope
Benchmark more sizes and alignments. Make the figures bigger to make the text smaller. Put the 'this' results first.
54
    pylab.savefig('alignment-%(function)s-%(bytes)d.png' % locals(), dpi=72)
33 by Michael Hope
Various updates to the benchmark plotting scripts.
55
56
def main():
57
    records = libplot.parse()
58
59
    for function in libplot.unique(records, 'function'):
60
        for bytes in libplot.unique(records, 'bytes'):
61
            plot(records, bytes, function)
62
63
    pylab.show()
64
65
if __name__ == '__main__':
66
    main()