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

« back to all changes in this revision

Viewing changes to scripts/plot-align.py

  • Committer: Michael Hope
  • Date: 2010-09-10 01:34:33 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: michael.hope@linaro.org-20100910013433-3ehxlbloizs3pqwg
Fixed up the Makefile so a 'make dist' includes everything required.

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', prefer='this')
15
 
    alignments = libplot.unique(records, ('src_alignment', 'dst_alignment'))
16
 
 
17
 
    X = pylab.arange(len(alignments))
18
 
    width = 1.0/(len(variants)+1)
19
 
 
20
 
    colours = iter('bgrcmyk')
21
 
 
22
 
    pylab.figure(1).set_size_inches((16, 12))
23
 
    pylab.clf()
24
 
 
25
 
    for i, variant in enumerate(variants):
26
 
        heights = []
27
 
 
28
 
        for alignment in alignments:
29
 
            matches = [x for x in records if x.variant==variant and x.src_alignment==alignment[0] and x.dst_alignment==alignment[1]]
30
 
 
31
 
            if matches:
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)
36
 
            else:
37
 
                heights.append(0)
38
 
 
39
 
        pylab.bar(X+i*width, heights, width, color=colours.next(), label=variant)
40
 
 
41
 
 
42
 
    axes = pylab.axes()
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)
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)')
52
 
    pylab.legend(loc='upper left', ncol=3)
53
 
    pylab.grid()
54
 
    pylab.savefig('alignment-%(function)s-%(bytes)d.png' % locals(), dpi=72)
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()