1
"""Shared routines for the plotters."""
6
Record = collections.namedtuple('Record', 'variant function bytes loops alignment elapsed rest')
10
return iter('m b g r c y k pink orange brown grey'.split())
13
"""Turn text into a primitive"""
23
def unique(records, name, prefer=''):
24
"""Return the unique values of a column in the records"""
25
values = list(set(getattr(x, name) for x in records))
29
elif type(values[0]) == str:
30
return sorted(values, key=lambda x: '%-06d|%s' % (-prefer.find(x), x))
35
return Record(*[parse_value(y) for y in line.split(':')])
38
"""Parse a record file into named tuples, correcting for loop
39
overhead along the way.
41
records = [parse_row(x) for x in fileinput.input()]
43
# Pull out any bounce values
46
for record in [x for x in records if x.function=='bounce']:
47
costs[(record.bytes, record.loops)] = record.elapsed
49
# Fix up all of the records for cost
52
for record in records:
53
if record.function == 'bounce':
56
cost = costs.get((record.bytes, record.loops), None)
61
# Unfortunately you can't update a namedtuple...
64
out.append(Record(*values))