OLD | NEW |
---|---|
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 Loading... | |
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 that the config file contents is a valid perf config, and all | |
qyearsley
2014/04/10 17:58:22
Nit: This wording is a little bit redundant, since
shatch
2014/04/10 18:21:11
Done.
| |
120 the values are 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 for v in config_contents.values() if v] | |
qyearsley
2014/04/10 17:58:22
What if the value used for truncate_percent was 0?
shatch
2014/04/10 18:21:11
Yeah, they've traditionally just been strings. Add
| |
133 return config_has_values | |
134 except KeyError: | |
135 return False | |
136 | |
137 | |
138 def _ValidatePerfConfigFile(config_contents): | |
139 """Validates that the config file contents is a valid perf config. | |
qyearsley
2014/04/10 17:58:22
I wasn't aware before that there was such a thing
shatch
2014/04/10 18:21:11
Done.
| |
140 | |
141 Args: | |
142 config_contents: Contents of the config file passed from _LoadConfigFile. | |
143 | |
144 Returns: | |
145 True if valid. | |
146 """ | |
147 valid_parameters = ['command', 'metric', 'repeat_count', 'truncate_percent', | |
148 'max_time_minutes'] | |
149 return _ValidateConfigFile(config_contents, valid_parameters) | |
150 | |
151 | |
152 def _ValidateBisectConfigFile(config_contents): | |
153 """Validates that the config file contents is a valid bisect config. | |
154 | |
155 Args: | |
156 config_contents: Contents of the config file passed from _LoadConfigFile. | |
157 | |
158 Returns: | |
159 True if valid. | |
160 """ | |
161 valid_params = ['command', 'good_revision', 'bad_revision', 'metric', | |
162 'repeat_count', 'truncate_percent', 'max_time_minutes'] | |
163 return _ValidateConfigFile(config_contents, valid_params) | |
164 | |
165 | |
118 def _OutputFailedResults(text_to_print): | 166 def _OutputFailedResults(text_to_print): |
119 bisect_utils.OutputAnnotationStepStart('Results - Failed') | 167 bisect_utils.OutputAnnotationStepStart('Results - Failed') |
120 print | 168 print |
121 print text_to_print | 169 print text_to_print |
122 print | 170 print |
123 bisect_utils.OutputAnnotationStepClosed() | 171 bisect_utils.OutputAnnotationStepClosed() |
124 | 172 |
125 | 173 |
126 def _CreateBisectOptionsFromConfig(config): | 174 def _CreateBisectOptionsFromConfig(config): |
127 opts_dict = {} | 175 opts_dict = {} |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 parser = optparse.OptionParser(usage=usage) | 410 parser = optparse.OptionParser(usage=usage) |
363 parser.add_option('-w', '--working_directory', | 411 parser.add_option('-w', '--working_directory', |
364 type='str', | 412 type='str', |
365 help='A working directory to supply to the bisection ' | 413 help='A working directory to supply to the bisection ' |
366 'script, which will use it as the location to checkout ' | 414 'script, which will use it as the location to checkout ' |
367 'a copy of the chromium depot.') | 415 'a copy of the chromium depot.') |
368 parser.add_option('-p', '--path_to_goma', | 416 parser.add_option('-p', '--path_to_goma', |
369 type='str', | 417 type='str', |
370 help='Path to goma directory. If this is supplied, goma ' | 418 help='Path to goma directory. If this is supplied, goma ' |
371 'builds will be enabled.') | 419 'builds will be enabled.') |
420 parser.add_option('--path_to_config', | |
421 type='str', | |
422 help='Path to the config file to use. If this is supplied, ' | |
423 'the bisect script will use this to override the default ' | |
424 'config file path.') | |
372 parser.add_option('--extra_src', | 425 parser.add_option('--extra_src', |
373 type='str', | 426 type='str', |
374 help='Path to extra source file. If this is supplied, ' | 427 help='Path to extra source file. If this is supplied, ' |
375 'bisect script will use this to override default behavior.') | 428 'bisect script will use this to override default behavior.') |
376 parser.add_option('--dry_run', | 429 parser.add_option('--dry_run', |
377 action="store_true", | 430 action="store_true", |
378 help='The script will perform the full bisect, but ' | 431 help='The script will perform the full bisect, but ' |
379 'without syncing, building, or running the performance ' | 432 'without syncing, building, or running the performance ' |
380 'tests.') | 433 'tests.') |
381 (opts, args) = parser.parse_args() | 434 (opts, args) = parser.parse_args() |
382 | 435 |
383 path_to_current_directory = os.path.abspath(os.path.dirname(sys.argv[0])) | 436 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, | 437 |
385 'run-bisect-perf-regression.cfg') | 438 # If they've specified their own config file, use that instead. |
439 if opts.path_to_config: | |
440 path_to_bisect_cfg = opts.path_to_config | |
qyearsley
2014/04/10 17:58:22
At this point, we're not 100% sure whether they've
shatch
2014/04/10 18:21:11
True, added some changes so that if loading it as
| |
441 else: | |
442 path_to_bisect_cfg = os.path.join(path_to_current_directory, | |
443 'run-bisect-perf-regression.cfg') | |
386 | 444 |
387 config = _LoadConfigFile(path_to_bisect_cfg) | 445 config = _LoadConfigFile(path_to_bisect_cfg) |
388 | 446 |
389 # Check if the config is empty | 447 # Check if the config is valid. |
390 config_has_values = [v for v in config.values() if v] | 448 config_is_valid = _ValidateBisectConfigFile(config) |
391 | 449 |
392 if config and config_has_values: | 450 if config and config_is_valid: |
393 if not opts.working_directory: | 451 if not opts.working_directory: |
394 print 'Error: missing required parameter: --working_directory' | 452 print 'Error: missing required parameter: --working_directory' |
395 print | 453 print |
396 parser.print_help() | 454 parser.print_help() |
397 return 1 | 455 return 1 |
398 | 456 |
399 return _RunBisectionScript(config, opts.working_directory, | 457 return _RunBisectionScript(config, opts.working_directory, |
400 path_to_current_directory, opts.path_to_goma, opts.extra_src, | 458 path_to_current_directory, opts.path_to_goma, opts.extra_src, |
401 opts.dry_run) | 459 opts.dry_run) |
402 else: | 460 else: |
403 perf_cfg_files = ['run-perf-test.cfg', os.path.join('..', 'third_party', | 461 perf_cfg_files = ['run-perf-test.cfg', os.path.join('..', 'third_party', |
404 'WebKit', 'Tools', 'run-perf-test.cfg')] | 462 'WebKit', 'Tools', 'run-perf-test.cfg')] |
405 | 463 |
406 for current_perf_cfg_file in perf_cfg_files: | 464 for current_perf_cfg_file in perf_cfg_files: |
407 path_to_perf_cfg = os.path.join( | 465 path_to_perf_cfg = os.path.join( |
408 os.path.abspath(os.path.dirname(sys.argv[0])), current_perf_cfg_file) | 466 os.path.abspath(os.path.dirname(sys.argv[0])), current_perf_cfg_file) |
409 | 467 |
410 config = _LoadConfigFile(path_to_perf_cfg) | 468 config = _LoadConfigFile(path_to_perf_cfg) |
411 config_has_values = [v for v in config.values() if v] | 469 config_is_valid = _ValidatePerfConfigFile(config) |
412 | 470 |
413 if config and config_has_values: | 471 if config and config_is_valid: |
414 return _SetupAndRunPerformanceTest(config, path_to_current_directory, | 472 return _SetupAndRunPerformanceTest(config, path_to_current_directory, |
415 opts.path_to_goma) | 473 opts.path_to_goma) |
416 | 474 |
417 print 'Error: Could not load config file. Double check your changes to '\ | 475 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.' | 476 'run-bisect-perf-regression.cfg/run-perf-test.cfg for syntax errors.' |
419 print | 477 print |
420 return 1 | 478 return 1 |
421 | 479 |
422 | 480 |
423 if __name__ == '__main__': | 481 if __name__ == '__main__': |
424 sys.exit(main()) | 482 sys.exit(main()) |
OLD | NEW |