Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python | |
| 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import re | |
| 7 import sys | |
| 8 | |
| 9 # Combine chromium-style perf log output from multiple runs. | |
| 10 # Input is text *containing* the chrome buildbot perf format (may contain more) | |
| 11 # but the output is only the merged perf data (throws away the rest). | |
| 12 | |
| 13 ACCUMULATED_TIMES = dict() | |
|
Nick Bray
2011/11/07 23:39:09
{} preferred to dict(), but really - I'd rather se
jvoung - send to chromium...
2011/11/09 00:50:54
oops, done.
| |
| 14 | |
| 15 RESULT_MATCHER = re.compile(r'^RESULT (.*): (.*)= (.*) (.*)$') | |
| 16 | |
| 17 def list_to_string(l): | |
|
Nick Bray
2011/11/07 23:39:09
CammelCase
jvoung - send to chromium...
2011/11/09 00:50:54
Done.
| |
| 18 return '[%s]' % (','.join(l)) | |
| 19 | |
|
Nick Bray
2011/11/07 23:39:09
Two lines between functions
jvoung - send to chromium...
2011/11/09 00:50:54
Done.
| |
| 20 def Main(): | |
| 21 usage = 'usage: %prog < stdin\n' | |
| 22 if len(sys.argv) != 1: | |
| 23 sys.stderr.write(usage) | |
| 24 sys.stderr.write('Instead, argv was %s\n' % str(sys.argv)) | |
| 25 return 1 | |
| 26 for line in sys.stdin.readlines(): | |
| 27 match = RESULT_MATCHER.match(line) | |
| 28 if match: | |
| 29 graph, trace, value, unit = match.groups() | |
| 30 key = (graph, trace) | |
| 31 value_list, old_unit = ACCUMULATED_TIMES.get(key, ([], None)) | |
| 32 if old_unit is not None: | |
| 33 assert(unit == old_unit) | |
| 34 if type(value) == list: | |
| 35 value_list += value | |
| 36 else: | |
| 37 value_list += [value] | |
| 38 ACCUMULATED_TIMES[key] = (value_list, unit) | |
| 39 for ((graph, trace), (values, unit)) in ACCUMULATED_TIMES.iteritems(): | |
| 40 sys.stdout.write('RESULT %s: %s= %s %s\n' % | |
| 41 (graph, trace, list_to_string(values), unit)) | |
| 42 return 0 | |
| 43 | |
| 44 if __name__ == '__main__': | |
| 45 sys.exit(Main()) | |
| OLD | NEW |