Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(780)

Side by Side Diff: perf_insights/perf_insights/map_traces.py

Issue 1417883005: Enable vulcanizing perf_insights mapper Base URL: https://github.com/catapult-project/catapult@master
Patch Set: Undo changes to vinn Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import argparse 4 import argparse
5 import os 5 import os
6 import sys 6 import sys
7 import traceback 7 import traceback
8 8
9 import perf_insights 9 import perf_insights
10 from perf_insights import local_directory_corpus_driver 10 from perf_insights import local_directory_corpus_driver
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 50
51 def Main(argv): 51 def Main(argv):
52 parser = argparse.ArgumentParser( 52 parser = argparse.ArgumentParser(
53 description='Bulk trace processing') 53 description='Bulk trace processing')
54 parser.add_argument( 54 parser.add_argument(
55 '-c', '--corpus', 55 '-c', '--corpus',
56 choices=_CORPUS_DRIVERS.keys(), 56 choices=_CORPUS_DRIVERS.keys(),
57 default=_CORPUS_DRIVER_DEFAULT) 57 default=_CORPUS_DRIVER_DEFAULT)
58 parser.add_argument('--query') 58 parser.add_argument('--query')
59 parser.add_argument('map_file') 59 parser.add_argument('map_function_name')
60 parser.add_argument('--map-file')
60 61
62 parser.add_argument('--no-vulcanize', dest='vulcanize',
63 action='store_false', default=True)
61 parser.add_argument('-j', '--jobs', type=int, default=1) 64 parser.add_argument('-j', '--jobs', type=int, default=1)
62 parser.add_argument('-o', '--output-file') 65 parser.add_argument('-o', '--output-file')
63 parser.add_argument('-s', '--stop-on-error', 66 parser.add_argument('-s', '--stop-on-error',
64 action='store_true') 67 action='store_true')
65 68
66 for k, v in _CORPUS_DRIVERS.iteritems(): 69 for k, v in _CORPUS_DRIVERS.iteritems():
67 if not v: 70 if not v:
68 continue 71 continue
69 parser_group = parser.add_argument_group(k) 72 parser_group = parser.add_argument_group(k)
70 driver_cls = v['class'] 73 driver_cls = v['class']
(...skipping 11 matching lines...) Expand all
82 corpus_descriptions = '\n'.join( 85 corpus_descriptions = '\n'.join(
83 ['%s: %s' % (k, v['description']) 86 ['%s: %s' % (k, v['description'])
84 for k, v in _CORPUS_DRIVERS.iteritems() if v] 87 for k, v in _CORPUS_DRIVERS.iteritems() if v]
85 ) 88 )
86 parser.exit('Valid drivers:\n\n%s\n' % corpus_descriptions) 89 parser.exit('Valid drivers:\n\n%s\n' % corpus_descriptions)
87 90
88 cls = _CORPUS_DRIVERS[corpus]['class'] 91 cls = _CORPUS_DRIVERS[corpus]['class']
89 init_args = cls.CheckAndCreateInitArguments(parser, args) 92 init_args = cls.CheckAndCreateInitArguments(parser, args)
90 corpus_driver = cls(**init_args) 93 corpus_driver = cls(**init_args)
91 94
92 if not os.path.exists(args.map_file): 95 if args.map_file and not os.path.exists(args.map_file):
93 parser.error('Map does not exist.') 96 parser.error('Map does not exist.')
94 97
95 if args.query == 'help': 98 if args.query == 'help':
96 parser.exit(_CORPUS_QUERY_HELP) 99 parser.exit(_CORPUS_QUERY_HELP)
97 elif args.query is None: 100 elif args.query is None:
98 query = corpus_query.CorpusQuery.FromString('True') 101 query = corpus_query.CorpusQuery.FromString('True')
99 else: 102 else:
100 query = corpus_query.CorpusQuery.FromString(args.query) 103 query = corpus_query.CorpusQuery.FromString(args.query)
101 104
102 if args.output_file: 105 if args.output_file:
103 ofile = open(args.output_file, 'w') 106 ofile = open(args.output_file, 'w')
104 else: 107 else:
105 ofile = sys.stdout 108 ofile = sys.stdout
106 109
107 output_formatter = json_output_formatter.JSONOutputFormatter(ofile) 110 output_formatter = json_output_formatter.JSONOutputFormatter(ofile)
108 111
112 map_file_path = None
113 if args.map_file:
114 map_file_path = os.path.abspath(args.map_file)
109 map_function_handle = map_function_handle_module.MapFunctionHandle( 115 map_function_handle = map_function_handle_module.MapFunctionHandle(
110 filename=os.path.abspath(args.map_file)) 116 filename=map_file_path, map_function_name=args.map_function_name)
111 try: 117 try:
112 trace_handles = corpus_driver.GetTraceHandlesMatchingQuery(query) 118 trace_handles = corpus_driver.GetTraceHandlesMatchingQuery(query)
113 runner = map_runner.MapRunner(trace_handles, map_function_handle, 119 runner = map_runner.MapRunner(trace_handles, map_function_handle,
114 stop_on_error=args.stop_on_error) 120 stop_on_error=args.stop_on_error,
121 vulcanize=args.vulcanize)
115 results = runner.Run(jobs=args.jobs, output_formatters=[output_formatter]) 122 results = runner.Run(jobs=args.jobs, output_formatters=[output_formatter])
116 if not results.had_failures: 123 if not results.had_failures:
117 return 0 124 return 0
118 else: 125 else:
119 return 255 126 return 255
120 finally: 127 finally:
121 if ofile != sys.stdout: 128 if ofile != sys.stdout:
122 ofile.close() 129 ofile.close()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698