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

Side by Side Diff: tools/run-bisect-perf-regression.py

Issue 232083003: [bisect] - Add --path_to_config parameter to run script. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes from review. Created 6 years, 8 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Run Performance Test Bisect Tool 6 """Run Performance Test Bisect Tool
7 7
8 This script is used by a trybot to run the src/tools/bisect-perf-regression.py 8 This script is used by a trybot to run the src/tools/bisect-perf-regression.py
9 script with the parameters specified in run-bisect-perf-regression.cfg. It will 9 script with the parameters specified in run-bisect-perf-regression.cfg. It will
10 check out a copy of the depot in a subdirectory 'bisect' of the working 10 check out a copy of the depot in a subdirectory 'bisect' of the working
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 execfile(path_to_file, local_vars) 108 execfile(path_to_file, local_vars)
109 109
110 return local_vars['config'] 110 return local_vars['config']
111 except: 111 except:
112 print 112 print
113 traceback.print_exc() 113 traceback.print_exc()
114 print 114 print
115 return {} 115 return {}
116 116
117 117
118 def _ValidateConfigFile(config_contents, valid_parameters):
119 """Validates the config file contents, checking whether all values are
120 non-empty.
121
122 Args:
123 config_contents: Contents of the config file passed from _LoadConfigFile.
124 valid_parameters: A list of parameters to check for.
125
126 Returns:
127 True if valid.
128 """
129 try:
130 [config_contents[current_parameter]
131 for current_parameter in valid_parameters]
132 config_has_values = [v and type(v) is str
133 for v in config_contents.values() if v]
134 return config_has_values
135 except KeyError:
136 return False
137
138
139 def _ValidatePerfConfigFile(config_contents):
140 """Validates that the perf config file contents. This is used when we're
141 doing a perf try job, rather than a bisect. The file is called
142 run-perf-test.cfg by default.
143
144 The parameters checked are the required parameters; any additional optional
145 parameters won't be checked and validation will still pass.
146
147 Args:
148 config_contents: Contents of the config file passed from _LoadConfigFile.
149
150 Returns:
151 True if valid.
152 """
153 valid_parameters = ['command', 'metric', 'repeat_count', 'truncate_percent',
154 'max_time_minutes']
155 return _ValidateConfigFile(config_contents, valid_parameters)
156
157
158 def _ValidateBisectConfigFile(config_contents):
159 """Validates that the bisect config file contents. The parameters checked are
160 the required parameters; any additional optional parameters won't be checked
161 and validation will still pass.
162
163 Args:
164 config_contents: Contents of the config file passed from _LoadConfigFile.
165
166 Returns:
167 True if valid.
168 """
169 valid_params = ['command', 'good_revision', 'bad_revision', 'metric',
170 'repeat_count', 'truncate_percent', 'max_time_minutes']
171 return _ValidateConfigFile(config_contents, valid_params)
172
173
118 def _OutputFailedResults(text_to_print): 174 def _OutputFailedResults(text_to_print):
119 bisect_utils.OutputAnnotationStepStart('Results - Failed') 175 bisect_utils.OutputAnnotationStepStart('Results - Failed')
120 print 176 print
121 print text_to_print 177 print text_to_print
122 print 178 print
123 bisect_utils.OutputAnnotationStepClosed() 179 bisect_utils.OutputAnnotationStepClosed()
124 180
125 181
126 def _CreateBisectOptionsFromConfig(config): 182 def _CreateBisectOptionsFromConfig(config):
127 opts_dict = {} 183 opts_dict = {}
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 parser = optparse.OptionParser(usage=usage) 418 parser = optparse.OptionParser(usage=usage)
363 parser.add_option('-w', '--working_directory', 419 parser.add_option('-w', '--working_directory',
364 type='str', 420 type='str',
365 help='A working directory to supply to the bisection ' 421 help='A working directory to supply to the bisection '
366 'script, which will use it as the location to checkout ' 422 'script, which will use it as the location to checkout '
367 'a copy of the chromium depot.') 423 'a copy of the chromium depot.')
368 parser.add_option('-p', '--path_to_goma', 424 parser.add_option('-p', '--path_to_goma',
369 type='str', 425 type='str',
370 help='Path to goma directory. If this is supplied, goma ' 426 help='Path to goma directory. If this is supplied, goma '
371 'builds will be enabled.') 427 'builds will be enabled.')
428 parser.add_option('--path_to_config',
429 type='str',
430 help='Path to the config file to use. If this is supplied, '
431 'the bisect script will use this to override the default '
432 'config file path. The script will attempt to load it '
433 'as a bisect config first, then a perf config.')
372 parser.add_option('--extra_src', 434 parser.add_option('--extra_src',
373 type='str', 435 type='str',
374 help='Path to extra source file. If this is supplied, ' 436 help='Path to extra source file. If this is supplied, '
375 'bisect script will use this to override default behavior.') 437 'bisect script will use this to override default behavior.')
376 parser.add_option('--dry_run', 438 parser.add_option('--dry_run',
377 action="store_true", 439 action="store_true",
378 help='The script will perform the full bisect, but ' 440 help='The script will perform the full bisect, but '
379 'without syncing, building, or running the performance ' 441 'without syncing, building, or running the performance '
380 'tests.') 442 'tests.')
381 (opts, args) = parser.parse_args() 443 (opts, args) = parser.parse_args()
382 444
383 path_to_current_directory = os.path.abspath(os.path.dirname(sys.argv[0])) 445 path_to_current_directory = os.path.abspath(os.path.dirname(sys.argv[0]))
384 path_to_bisect_cfg = os.path.join(path_to_current_directory, 446
385 'run-bisect-perf-regression.cfg') 447 # If they've specified their own config file, use that instead.
448 if opts.path_to_config:
449 path_to_bisect_cfg = opts.path_to_config
450 else:
451 path_to_bisect_cfg = os.path.join(path_to_current_directory,
452 'run-bisect-perf-regression.cfg')
386 453
387 config = _LoadConfigFile(path_to_bisect_cfg) 454 config = _LoadConfigFile(path_to_bisect_cfg)
388 455
389 # Check if the config is empty 456 # Check if the config is valid.
390 config_has_values = [v for v in config.values() if v] 457 config_is_valid = _ValidateBisectConfigFile(config)
391 458
392 if config and config_has_values: 459 if config and config_is_valid:
393 if not opts.working_directory: 460 if not opts.working_directory:
394 print 'Error: missing required parameter: --working_directory' 461 print 'Error: missing required parameter: --working_directory'
395 print 462 print
396 parser.print_help() 463 parser.print_help()
397 return 1 464 return 1
398 465
399 return _RunBisectionScript(config, opts.working_directory, 466 return _RunBisectionScript(config, opts.working_directory,
400 path_to_current_directory, opts.path_to_goma, opts.extra_src, 467 path_to_current_directory, opts.path_to_goma, opts.extra_src,
401 opts.dry_run) 468 opts.dry_run)
402 else: 469 else:
403 perf_cfg_files = ['run-perf-test.cfg', os.path.join('..', 'third_party', 470 perf_cfg_files = ['run-perf-test.cfg', os.path.join('..', 'third_party',
404 'WebKit', 'Tools', 'run-perf-test.cfg')] 471 'WebKit', 'Tools', 'run-perf-test.cfg')]
405 472
406 for current_perf_cfg_file in perf_cfg_files: 473 for current_perf_cfg_file in perf_cfg_files:
407 path_to_perf_cfg = os.path.join( 474 if opts.path_to_config:
408 os.path.abspath(os.path.dirname(sys.argv[0])), current_perf_cfg_file) 475 path_to_perf_cfg = opts.path_to_config
476 else:
477 path_to_perf_cfg = os.path.join(
478 os.path.abspath(os.path.dirname(sys.argv[0])),
479 current_perf_cfg_file)
409 480
410 config = _LoadConfigFile(path_to_perf_cfg) 481 config = _LoadConfigFile(path_to_perf_cfg)
411 config_has_values = [v for v in config.values() if v] 482 config_is_valid = _ValidatePerfConfigFile(config)
412 483
413 if config and config_has_values: 484 if config and config_is_valid:
414 return _SetupAndRunPerformanceTest(config, path_to_current_directory, 485 return _SetupAndRunPerformanceTest(config, path_to_current_directory,
415 opts.path_to_goma) 486 opts.path_to_goma)
416 487
417 print 'Error: Could not load config file. Double check your changes to '\ 488 print 'Error: Could not load config file. Double check your changes to '\
418 'run-bisect-perf-regression.cfg/run-perf-test.cfg for syntax errors.' 489 'run-bisect-perf-regression.cfg/run-perf-test.cfg for syntax errors.'
419 print 490 print
420 return 1 491 return 1
421 492
422 493
423 if __name__ == '__main__': 494 if __name__ == '__main__':
424 sys.exit(main()) 495 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698