| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 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 """A tool to run the dom perf tests, used by the buildbot slaves. | 6 """A tool to run the dom perf tests, used by the buildbot slaves. |
| 7 | 7 |
| 8 When this is run, the current directory (cwd) should be the outer build | 8 When this is run, the current directory (cwd) should be the outer build |
| 9 directory (e.g., chrome-release/build/). | 9 directory (e.g., chrome-release/build/). |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 # Compute the path to the test data. | 59 # Compute the path to the test data. |
| 60 src_dir = os.path.dirname(build_dir) | 60 src_dir = os.path.dirname(build_dir) |
| 61 data_dir = os.path.join(src_dir, 'data') | 61 data_dir = os.path.join(src_dir, 'data') |
| 62 dom_perf_dir = os.path.join(data_dir, 'dom_perf') | 62 dom_perf_dir = os.path.join(data_dir, 'dom_perf') |
| 63 | 63 |
| 64 iterations = '' # Default | 64 iterations = '' # Default |
| 65 if options.target == 'Debug': | 65 if options.target == 'Debug': |
| 66 iterations = '&minIterations=1' | 66 iterations = '&minIterations=1' |
| 67 | 67 |
| 68 # Windows used to write to the root of C:, but that doesn't work | 68 def run_and_print(use_refbuild): |
| 69 # on Vista so we write into the build folder instead. | 69 # Windows used to write to the root of C:, but that doesn't work |
| 70 output_file = os.path.join(build_dir, options.target, | 70 # on Vista so we write into the build folder instead. |
| 71 'dom_perf_result_%s.txt' % build_revision) | 71 suffix = '' |
| 72 if (use_refbuild): |
| 73 suffix = '_ref' |
| 74 output_file = os.path.join(build_dir, options.target, |
| 75 'dom_perf_result_%s%s.txt' % (build_revision, |
| 76 suffix)) |
| 72 | 77 |
| 73 url = URL % (dom_perf_dir, iterations, build_revision) | 78 url = URL % (dom_perf_dir, iterations, build_revision) |
| 74 url_flag = '--url=%s' % url | 79 url_flag = '--url=%s' % url |
| 75 | 80 |
| 76 command = [test_exe_path, | 81 command = [test_exe_path, |
| 77 '--wait_cookie_name=__domperf_finished', | 82 '--wait_cookie_name=__domperf_finished', |
| 78 '--jsvar=__domperf_result', | 83 '--jsvar=__domperf_result', |
| 79 '--jsvar_output=%s' % output_file, | 84 '--jsvar_output=%s' % output_file, |
| 80 url_flag] | 85 url_flag] |
| 86 if use_refbuild: |
| 87 command.append('--reference_build') |
| 81 | 88 |
| 82 print "Executing: " | 89 print "Executing: " |
| 83 print command | 90 print command |
| 84 result = chromium_utils.RunCommand(command) | 91 result = chromium_utils.RunCommand(command) |
| 85 | 92 |
| 86 # Open the resulting file and display it. | 93 # Open the resulting file and display it. |
| 87 file = open(output_file, 'r') | 94 file = open(output_file, 'r') |
| 88 data = json.loads(''.join(file.readlines())) | 95 data = json.loads(''.join(file.readlines())) |
| 89 file.close() | 96 file.close() |
| 97 |
| 98 name = 'Total' |
| 99 if use_refbuild: |
| 100 name += '_ref' |
| 101 print_result(True, name, data['BenchmarkRun']['totalScore']) |
| 102 for suite in data['BenchmarkSuites']: |
| 103 name = suite['name'] |
| 104 if use_refbuild: |
| 105 name += '_ref' |
| 106 print_result(False, name, suite['score']) |
| 107 |
| 108 return result |
| 109 |
| 110 result = run_and_print(False) |
| 111 result &= run_and_print(True) |
| 90 | 112 |
| 91 if chromium_utils.IsLinux(): | 113 if chromium_utils.IsLinux(): |
| 92 slave_utils.StopVirtualX(options.target) | 114 slave_utils.StopVirtualX(options.target) |
| 93 | 115 |
| 94 print_result(True, 'Total', data['BenchmarkRun']['totalScore']) | |
| 95 for suite in data['BenchmarkSuites']: | |
| 96 print_result(False, suite['name'], suite['score']) | |
| 97 | |
| 98 return result | 116 return result |
| 99 | 117 |
| 100 | 118 |
| 101 if '__main__' == __name__: | 119 if '__main__' == __name__: |
| 102 # Initialize logging. | 120 # Initialize logging. |
| 103 log_level = logging.INFO | 121 log_level = logging.INFO |
| 104 logging.basicConfig(level=log_level, | 122 logging.basicConfig(level=log_level, |
| 105 format='%(asctime)s %(filename)s:%(lineno)-3d' | 123 format='%(asctime)s %(filename)s:%(lineno)-3d' |
| 106 ' %(levelname)s %(message)s', | 124 ' %(levelname)s %(message)s', |
| 107 datefmt='%y%m%d %H:%M:%S') | 125 datefmt='%y%m%d %H:%M:%S') |
| 108 | 126 |
| 109 option_parser = optparse.OptionParser(usage=USAGE) | 127 option_parser = optparse.OptionParser(usage=USAGE) |
| 110 | 128 |
| 111 option_parser.add_option('', '--target', default='Release', | 129 option_parser.add_option('', '--target', default='Release', |
| 112 help='build target (Debug or Release)') | 130 help='build target (Debug or Release)') |
| 113 option_parser.add_option('', '--build-dir', default='chrome', | 131 option_parser.add_option('', '--build-dir', default='chrome', |
| 114 help='path to main build directory (the parent of ' | 132 help='path to main build directory (the parent of ' |
| 115 'the Release or Debug directory)') | 133 'the Release or Debug directory)') |
| 116 options, args = option_parser.parse_args() | 134 options, args = option_parser.parse_args() |
| 117 | 135 |
| 118 sys.exit(main(options, args)) | 136 sys.exit(main(options, args)) |
| OLD | NEW |