Chromium Code Reviews| Index: tools/process_perf_combined.py |
| =================================================================== |
| --- tools/process_perf_combined.py (revision 0) |
| +++ tools/process_perf_combined.py (revision 0) |
| @@ -0,0 +1,45 @@ |
| +#!/usr/bin/python |
| +# Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import re |
| +import sys |
| + |
| +# Combine chromium-style perf log output from multiple runs. |
| +# Input is text *containing* the chrome buildbot perf format (may contain more) |
| +# but the output is only the merged perf data (throws away the rest). |
| + |
| +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.
|
| + |
| +RESULT_MATCHER = re.compile(r'^RESULT (.*): (.*)= (.*) (.*)$') |
| + |
| +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.
|
| + return '[%s]' % (','.join(l)) |
| + |
|
Nick Bray
2011/11/07 23:39:09
Two lines between functions
jvoung - send to chromium...
2011/11/09 00:50:54
Done.
|
| +def Main(): |
| + usage = 'usage: %prog < stdin\n' |
| + if len(sys.argv) != 1: |
| + sys.stderr.write(usage) |
| + sys.stderr.write('Instead, argv was %s\n' % str(sys.argv)) |
| + return 1 |
| + for line in sys.stdin.readlines(): |
| + match = RESULT_MATCHER.match(line) |
| + if match: |
| + graph, trace, value, unit = match.groups() |
| + key = (graph, trace) |
| + value_list, old_unit = ACCUMULATED_TIMES.get(key, ([], None)) |
| + if old_unit is not None: |
| + assert(unit == old_unit) |
| + if type(value) == list: |
| + value_list += value |
| + else: |
| + value_list += [value] |
| + ACCUMULATED_TIMES[key] = (value_list, unit) |
| + for ((graph, trace), (values, unit)) in ACCUMULATED_TIMES.iteritems(): |
| + sys.stdout.write('RESULT %s: %s= %s %s\n' % |
| + (graph, trace, list_to_string(values), unit)) |
| + return 0 |
| + |
| +if __name__ == '__main__': |
| + sys.exit(Main()) |
| Property changes on: tools/process_perf_combined.py |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |