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

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
33 by Michael Hope
Various updates to the benchmark plotting scripts.
22
def plot(records, function, alignment=None):
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
35
    colours = iter('bgrcmyk')
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
49 by Michael Hope
Benchmark more sizes and alignments. Make the figures bigger to make the text smaller. Put the 'this' results first.
38
    pylab.figure(1).set_size_inches((16, 12))
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
49 by Michael Hope
Benchmark more sizes and alignments. Make the figures bigger to make the text smaller. Put the 'this' results first.
62
    pylab.legend(loc='upper left', ncol=3)
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:
88
            plot(records, function, alignment)
49 by Michael Hope
Benchmark more sizes and alignments. Make the figures bigger to make the text smaller. Put the 'this' results first.
89
            pylab.savefig('sizes-%s-%02d.png' % (function, alignment), dpi=72)
44 by Michael Hope
Various plotting updates.
90
91
    pylab.show()
29 by Michael Hope
Added some scripts to run the benchmarks and to plot the results.
92
93
if __name__ == '__main__':
94
    main()
95