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

« back to all changes in this revision

Viewing changes to scripts/plot-sizes.py

  • Committer: Michael Hope
  • Date: 2011-09-02 00:18:24 UTC
  • Revision ID: michael.hope@linaro.org-20110902001824-rklwpoiungg4u2bs
Various plotting updates.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
import pylab
10
10
import pdb
11
11
 
 
12
def pretty_kb(v):
 
13
    if v < 1024:
 
14
        return '%d' % v
 
15
    else:
 
16
        if v % 1024 == 0:
 
17
            return '%d k' % (v//1024)
 
18
        else:
 
19
            return '%.1f k' % (v/1024)
 
20
 
12
21
def plot(records, function, alignment=None):
13
 
    variants = libplot.unique(records, 'variant')
 
22
    variants = libplot.unique(records, 'variant', prefer='this')
14
23
    records = [x for x in records if x.function==function]
15
24
 
16
25
    if alignment != None:
43
52
 
44
53
    pylab.legend(loc='upper left')
45
54
    pylab.grid()
46
 
    pylab.title('%(function)s of %(aalignment)s byte aligned, %(bytes)s byte blocks' % locals())
 
55
    pylab.title('%(function)s of %(aalignment)s byte aligned blocks' % locals())
47
56
    pylab.xlabel('Size (B)')
48
57
    pylab.ylabel('Rate (MB/s)')
49
58
    pylab.semilogx()
 
59
    pylab.axes().set_xticks([2**x for x in range(0, 15)])
 
60
    pylab.axes().set_xticklabels([pretty_kb(2**x) for x in range(0, 15)])
50
61
    pylab.xlim(0, max(all_x))
51
62
    pylab.ylim(0, pylab.ylim()[1])
52
63
 
54
65
    records = libplot.parse()
55
66
 
56
67
    functions = libplot.unique(records, 'function')
 
68
    alignments = libplot.unique(records, 'alignment')
57
69
 
58
70
    for function in functions:
59
 
        plot(records, function)
60
 
        pylab.savefig('sizes-%s.png' % function)
 
71
        for alignment in alignments:
 
72
            plot(records, function, alignment)
 
73
            pylab.savefig('sizes-%s-%d.png' % (function, alignment))
 
74
 
 
75
    pylab.show()
61
76
 
62
77
if __name__ == '__main__':
63
78
    main()