| 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 |
| 11 For a list of command-line options, call this script with '--help'. | 11 For a list of command-line options, call this script with '--help'. |
| 12 """ | 12 """ |
| 13 | 13 |
| 14 import logging | 14 import logging |
| 15 import optparse | 15 import optparse |
| 16 import os | 16 import os |
| 17 import sys | 17 import sys |
| 18 | 18 |
| 19 import chromium_utils | 19 import chromium_utils |
| 20 import simplejson as json | 20 import simplejson as json |
| 21 import slave_utils | 21 import slave_utils |
| 22 | 22 |
| 23 # So we can import google.*_utils below with native Pythons. | 23 # So we can import google.*_utils below with native Pythons. |
| 24 sys.path.append(os.path.abspath('src/tools/python')) | 24 sys.path.append(os.path.abspath('src/tools/python')) |
| 25 | 25 |
| 26 USAGE = '%s [options]' % os.path.basename(sys.argv[0]) | 26 USAGE = '%s [options]' % os.path.basename(sys.argv[0]) |
| 27 | 27 |
| 28 URL = 'file:///%s/run.html?run=all%s&reportInJS=1&tags=buildbot_trunk,revision_%
s' | 28 URL = 'file:///%s/run.html?run=all%s&reportInJS=1&tags=buildbot_trunk,revision_%
s' |
| 29 | 29 |
| 30 def print_result(top, name, score_string): | 30 def print_result(top, name, score_string, refbuild): |
| 31 prefix = '' | 31 prefix = '' |
| 32 if top: | 32 if top: |
| 33 prefix = '*' | 33 prefix = '*' |
| 34 score = int(round(float(score_string))) | 34 score = int(round(float(score_string))) |
| 35 print ('%sRESULT %s: score= %d score (bigger is better)' % | 35 score_label = 'score' |
| 36 (prefix, name, score)) | 36 if refbuild: |
| 37 score_label = 'score_ref' |
| 38 print ('%sRESULT %s: %s= %d score (bigger is better)' % |
| 39 (prefix, name, score_label, score)) |
| 37 | 40 |
| 38 def main(options, args): | 41 def main(options, args): |
| 39 """Using the target build configuration, run the dom perf test.""" | 42 """Using the target build configuration, run the dom perf test.""" |
| 40 | 43 |
| 41 build_dir = os.path.abspath(options.build_dir) | 44 build_dir = os.path.abspath(options.build_dir) |
| 42 if chromium_utils.IsWindows(): | 45 if chromium_utils.IsWindows(): |
| 43 test_exe_name = 'url_fetch_test.exe' | 46 test_exe_name = 'url_fetch_test.exe' |
| 44 else: | 47 else: |
| 45 test_exe_name = 'url_fetch_test' | 48 test_exe_name = 'url_fetch_test' |
| 46 if chromium_utils.IsMac(): | 49 if chromium_utils.IsMac(): |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 91 |
| 89 print "Executing: " | 92 print "Executing: " |
| 90 print command | 93 print command |
| 91 result = chromium_utils.RunCommand(command) | 94 result = chromium_utils.RunCommand(command) |
| 92 | 95 |
| 93 # Open the resulting file and display it. | 96 # Open the resulting file and display it. |
| 94 file = open(output_file, 'r') | 97 file = open(output_file, 'r') |
| 95 data = json.loads(''.join(file.readlines())) | 98 data = json.loads(''.join(file.readlines())) |
| 96 file.close() | 99 file.close() |
| 97 | 100 |
| 98 name = 'Total' | 101 print_result(True, 'Total', data['BenchmarkRun']['totalScore'], |
| 99 if use_refbuild: | 102 use_refbuild) |
| 100 name += '_ref' | |
| 101 print_result(True, name, data['BenchmarkRun']['totalScore']) | |
| 102 for suite in data['BenchmarkSuites']: | 103 for suite in data['BenchmarkSuites']: |
| 103 name = suite['name'] | 104 print_result(False, suite['name'], suite['score'], use_refbuild) |
| 104 if use_refbuild: | |
| 105 name += '_ref' | |
| 106 print_result(False, name, suite['score']) | |
| 107 | 105 |
| 108 return result | 106 return result |
| 109 | 107 |
| 110 result = run_and_print(False) | 108 result = run_and_print(False) |
| 111 result &= run_and_print(True) | 109 result &= run_and_print(True) |
| 112 | 110 |
| 113 if chromium_utils.IsLinux(): | 111 if chromium_utils.IsLinux(): |
| 114 slave_utils.StopVirtualX(options.target) | 112 slave_utils.StopVirtualX(options.target) |
| 115 | 113 |
| 116 return result | 114 return result |
| (...skipping 10 matching lines...) Expand all Loading... |
| 127 option_parser = optparse.OptionParser(usage=USAGE) | 125 option_parser = optparse.OptionParser(usage=USAGE) |
| 128 | 126 |
| 129 option_parser.add_option('', '--target', default='Release', | 127 option_parser.add_option('', '--target', default='Release', |
| 130 help='build target (Debug or Release)') | 128 help='build target (Debug or Release)') |
| 131 option_parser.add_option('', '--build-dir', default='chrome', | 129 option_parser.add_option('', '--build-dir', default='chrome', |
| 132 help='path to main build directory (the parent of ' | 130 help='path to main build directory (the parent of ' |
| 133 'the Release or Debug directory)') | 131 'the Release or Debug directory)') |
| 134 options, args = option_parser.parse_args() | 132 options, args = option_parser.parse_args() |
| 135 | 133 |
| 136 sys.exit(main(options, args)) | 134 sys.exit(main(options, args)) |
| OLD | NEW |