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

30 by Michael Hope
Added more ranges. changed everything to MB/s. Account for the loop overhead.
1
"""Shared routines for the plotters."""
2
29 by Michael Hope
Added some scripts to run the benchmarks and to plot the results.
3
import fileinput
4
import collections
5
115 by Will Newton
Support multiple runs of each benchmark.
6
Record = collections.namedtuple('Record', 'variant function bytes loops src_alignment dst_alignment run_id elapsed rest')
29 by Michael Hope
Added some scripts to run the benchmarks and to plot the results.
7
8
80 by Michael Hope
Generate a tumbnail and full size for the size plots. Tweak the colours to have more and make the first a Linaro purple.
9
def make_colours():
10
    return iter('m b g r c y k pink orange brown grey'.split())
11
29 by Michael Hope
Added some scripts to run the benchmarks and to plot the results.
12
def parse_value(v):
30 by Michael Hope
Added more ranges. changed everything to MB/s. Account for the loop overhead.
13
    """Turn text into a primitive"""
29 by Michael Hope
Added some scripts to run the benchmarks and to plot the results.
14
    try:
33 by Michael Hope
Various updates to the benchmark plotting scripts.
15
        if '.' in v:
16
            return float(v)
17
        else:
18
            return int(v)
29 by Michael Hope
Added some scripts to run the benchmarks and to plot the results.
19
    except ValueError:
20
        return v
21
113 by Will Newton
Allow aligning source and destination buffers separately.
22
def create_column_tuple(record, names):
23
    cols = [getattr(record, name) for name in names]
24
    return tuple(cols)
29 by Michael Hope
Added some scripts to run the benchmarks and to plot the results.
25
33 by Michael Hope
Various updates to the benchmark plotting scripts.
26
def unique(records, name, prefer=''):
30 by Michael Hope
Added more ranges. changed everything to MB/s. Account for the loop overhead.
27
    """Return the unique values of a column in the records"""
113 by Will Newton
Allow aligning source and destination buffers separately.
28
    if type(name) == tuple:
29
        values = list(set(create_column_tuple(x, name) for x in records))
30
    else:
31
        values = list(set(getattr(x, name) for x in records))
44 by Michael Hope
Various plotting updates.
32
33
    if not values:
34
        return values
35
    elif type(values[0]) == str:
36
        return sorted(values, key=lambda x: '%-06d|%s' % (-prefer.find(x), x))
37
    else:
38
        return sorted(values)
29 by Michael Hope
Added some scripts to run the benchmarks and to plot the results.
39
113 by Will Newton
Allow aligning source and destination buffers separately.
40
def alignments_equal(alignments):
41
    for alignment in alignments:
42
        if alignment[0] != alignment[1]:
43
            return False
44
    return True
45
80 by Michael Hope
Generate a tumbnail and full size for the size plots. Tweak the colours to have more and make the first a Linaro purple.
46
def parse_row(line):
47
    return Record(*[parse_value(y) for y in line.split(':')])
48
29 by Michael Hope
Added some scripts to run the benchmarks and to plot the results.
49
def parse():
30 by Michael Hope
Added more ranges. changed everything to MB/s. Account for the loop overhead.
50
    """Parse a record file into named tuples, correcting for loop
51
    overhead along the way.
52
    """
80 by Michael Hope
Generate a tumbnail and full size for the size plots. Tweak the colours to have more and make the first a Linaro purple.
53
    records = [parse_row(x) for x in fileinput.input()]
30 by Michael Hope
Added more ranges. changed everything to MB/s. Account for the loop overhead.
54
55
    # Pull out any bounce values
56
    costs = {}
57
58
    for record in [x for x in records if x.function=='bounce']:
59
        costs[(record.bytes, record.loops)] = record.elapsed
60
61
    # Fix up all of the records for cost
62
    out = []
63
64
    for record in records:
65
        if record.function == 'bounce':
66
            continue
67
68
        cost = costs.get((record.bytes, record.loops), None)
69
70
        if not cost:
71
            out.append(record)
72
        else:
73
            # Unfortunately you can't update a namedtuple...
74
            values = list(record)
75
            values[-2] -= cost
76
            out.append(Record(*values))
77
78
    return out