Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2016 The Chromium 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 os | |
| 7 import sys | |
| 8 | |
| 9 tracing_path = os.path.abspath(os.path.join(os.path.dirname(__file__), | |
| 10 '..')) | |
| 11 sys.path.append(tracing_path) | |
| 12 from tracing.metrics import compare_samples | |
| 13 | |
| 14 def Main(argv): | |
| 15 parser = argparse.ArgumentParser( | |
| 16 description='Compare samples.') | |
| 17 parser.add_argument('sample_a', type=str, | |
| 18 help='comma-separated list of paths to valuesets from ' | |
| 19 'sample a') | |
| 20 parser.add_argument('sample_b', type=str, | |
| 21 help='comma-separated list of paths to valuesets from ' | |
| 22 'sample b') | |
| 23 parser.add_argument('metric', type=str, | |
| 24 help='name of the metric to compare') | |
| 25 parser.add_argument('--chartjson', dest='format', action='store_const', | |
| 26 const='chartjson', | |
| 27 help='assume chartjson format for the input data') | |
| 28 parser.add_argument('--buildbot', dest='format', action='store_const', | |
| 29 const='buildbot', | |
| 30 help='assume buildbot result line format for the data') | |
| 31 parser.add_argument('--valueset', dest='format', action='store_const', | |
| 32 const='valueset', | |
| 33 help='assume valueset format for the input data') | |
| 34 args = parser.parse_args(argv[1:]) | |
| 35 | |
| 36 if not args.format: | |
| 37 filename = os.path.basename(sample_a.split(',')[0]) | |
| 38 if filename == 'results-valueset.json': | |
| 39 args.format = 'valueset' | |
| 40 else: | |
| 41 args.format = 'chartjson' | |
| 42 | |
| 43 output = compare_samples.CompareSamples( | |
| 44 args.sample_a, | |
| 45 args.sample_b, | |
| 46 args.metric, | |
| 47 args.format | |
| 48 ) | |
| 49 print output | |
| 50 | |
| 51 try: | |
| 52 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.
| |
| 53 return 0 | |
| 54 except ValueError: | |
| 55 return 1 | |
| 56 | |
| 57 if __name__ == '__main__': | |
| 58 sys.exit(Main(sys.argv)) | |
| OLD | NEW |