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

« back to all changes in this revision

Viewing changes to scripts/plot-align.py

  • Committer: Michael Hope
  • Date: 2011-08-31 23:52:05 UTC
  • Revision ID: michael.hope@linaro.org-20110831235205-gwc0igvevvhyyop8
Various updates to the benchmark plotting scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
14
    variants = libplot.unique(records, 'variant')
 
15
    alignments = libplot.unique(records, 'alignment')
 
16
 
 
17
    X = pylab.arange(len(alignments))
 
18
    width = 1.0/(len(X)+1)
 
19
 
 
20
    colours = iter('bgrcmyk')
 
21
 
 
22
    pylab.clf()
 
23
 
 
24
    for i, variant in enumerate(variants):
 
25
        heights = []
 
26
 
 
27
        for alignment in alignments:
 
28
            matches = [x for x in records if x.variant==variant and x.alignment==alignment]
 
29
 
 
30
            if matches:
 
31
                match = matches[0]
 
32
                heights.append(match.bytes*match.loops/match.elapsed/(1024*1024))
 
33
            else:
 
34
                heights.append(0)
 
35
 
 
36
        pylab.bar(X+i*width, heights, width, color=colours.next(), label=variant)
 
37
 
 
38
    axes = pylab.axes()
 
39
    axes.set_xticklabels(alignments)
 
40
    axes.set_xticks(X + 0.5)
 
41
 
 
42
    pylab.title('Performance of different variants of %(function)s for %(bytes)d byte blocks' % locals())
 
43
    pylab.ylabel('Rate (MB/s)')
 
44
    pylab.legend(loc='upper left', ncol=2)
 
45
    pylab.grid()
 
46
    pylab.savefig('alignment-%(function)s-%(bytes)d.png' % locals())
 
47
 
 
48
def main():
 
49
    records = libplot.parse()
 
50
 
 
51
    for function in libplot.unique(records, 'function'):
 
52
        for bytes in libplot.unique(records, 'bytes'):
 
53
            plot(records, bytes, function)
 
54
 
 
55
    pylab.show()
 
56
 
 
57
if __name__ == '__main__':
 
58
    main()