Chromium Code Reviews| Index: tracing/bin/compare_samples |
| diff --git a/tracing/bin/compare_samples b/tracing/bin/compare_samples |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..445dfda049bff3b3747ebc1d111bcae8ba3f8542 |
| --- /dev/null |
| +++ b/tracing/bin/compare_samples |
| @@ -0,0 +1,58 @@ |
| +#!/usr/bin/env python |
| +# Copyright (c) 2016 The Chromium 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 os |
| +import sys |
| + |
| +tracing_path = os.path.abspath(os.path.join(os.path.dirname(__file__), |
| + '..')) |
| +sys.path.append(tracing_path) |
| +from tracing.metrics import compare_samples |
| + |
| +def Main(argv): |
| + parser = argparse.ArgumentParser( |
| + description='Compare samples.') |
| + parser.add_argument('sample_a', type=str, |
| + help='comma-separated list of paths to valuesets from ' |
| + 'sample a') |
| + parser.add_argument('sample_b', type=str, |
| + help='comma-separated list of paths to valuesets from ' |
| + 'sample b') |
| + parser.add_argument('metric', type=str, |
| + help='name of the metric to compare') |
| + parser.add_argument('--chartjson', dest='format', action='store_const', |
| + const='chartjson', |
| + help='assume chartjson format for the input data') |
| + parser.add_argument('--buildbot', dest='format', action='store_const', |
| + const='buildbot', |
| + help='assume buildbot result line format for the data') |
| + parser.add_argument('--valueset', dest='format', action='store_const', |
| + const='valueset', |
| + help='assume valueset format for the input data') |
| + args = parser.parse_args(argv[1:]) |
| + |
| + if not args.format: |
| + filename = os.path.basename(sample_a.split(',')[0]) |
| + if filename == 'results-valueset.json': |
| + args.format = 'valueset' |
| + else: |
| + args.format = 'chartjson' |
| + |
| + output = compare_samples.CompareSamples( |
| + args.sample_a, |
| + args.sample_b, |
| + args.metric, |
| + args.format |
| + ) |
| + print output |
| + |
| + try: |
| + json.loads(output) |
|
benjhayden
2016/09/27 06:25:54
Why not have CompareSamples return vinn's RunResul
RobertoCN
2016/09/27 22:58:48
Good Idea. Done.
|
| + return 0 |
| + except ValueError: |
| + return 1 |
| + |
| +if __name__ == '__main__': |
| + sys.exit(Main(sys.argv)) |