1
"""Shared routines for the plotters."""
6
Record = collections.namedtuple('Record', 'variant function bytes loops src_alignment dst_alignment run_id elapsed rest')
10
return iter('m b g r c y k pink orange brown grey'.split())
13
"""Turn text into a primitive"""
22
def create_column_tuple(record, names):
23
cols = [getattr(record, name) for name in names]
26
def unique(records, name, prefer=''):
27
"""Return the unique values of a column in the records"""
28
if type(name) == tuple:
29
values = list(set(create_column_tuple(x, name) for x in records))
31
values = list(set(getattr(x, name) for x in records))
35
elif type(values[0]) == str:
36
return sorted(values, key=lambda x: '%-06d|%s' % (-prefer.find(x), x))
40
def alignments_equal(alignments):
41
for alignment in alignments:
42
if alignment[0] != alignment[1]:
47
return Record(*[parse_value(y) for y in line.split(':')])
50
"""Parse a record file into named tuples, correcting for loop
51
overhead along the way.
53
records = [parse_row(x) for x in fileinput.input()]
55
# Pull out any bounce values
58
for record in [x for x in records if x.function=='bounce']:
59
costs[(record.bytes, record.loops)] = record.elapsed
61
# Fix up all of the records for cost
64
for record in records:
65
if record.function == 'bounce':
68
cost = costs.get((record.bytes, record.loops), None)
73
# Unfortunately you can't update a namedtuple...
76
out.append(Record(*values))