2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
12 BASE_URL
= 'http://src.chromium.org/chrome/trunk/'
13 DEPS_FILE
= 'bootstrap_deps'
15 SCRIPT_PATH
= os
.path
.dirname(os
.path
.abspath(__file__
))
16 # Directory containing src/ in a Chromium checkout.
17 CHECKOUT_BASE_PATH
= os
.path
.join(SCRIPT_PATH
, os
.pardir
, os
.pardir
, os
.pardir
)
18 # Directory in which to save bootstrap files.
19 BOOTSTRAP_BASE_PATH
= os
.path
.join(SCRIPT_PATH
, 'support', 'bootstrap_files')
21 CROS_DIR
= os
.path
.join('src', 'tools', 'cros')
22 PERF_DIR
= os
.path
.join('src', 'tools', 'perf')
23 TELEMETRY_DIR
= os
.path
.join('src', 'tools', 'telemetry')
24 TELEMETRY_TOOLS_DIR
= os
.path
.join('src', 'tools', 'telemetry_tools')
28 """Find the location of our Chromium or bootstrap checkout.
30 It tries to import Telemetry. If the import succeeds,
31 we assume that's the correct location.
34 The path containing the src/ directory, or None if no checkout is found.
36 module_name
= 'telemetry'
37 module_path
= TELEMETRY_DIR
40 paths
= [os
.path
.join(CHECKOUT_BASE_PATH
, module_path
)]
41 imp
.find_module(module_name
, paths
)
42 return CHECKOUT_BASE_PATH
47 paths
= [os
.path
.join(BOOTSTRAP_BASE_PATH
, module_path
)]
48 imp
.find_module(module_name
, paths
)
49 return BOOTSTRAP_BASE_PATH
56 def _Bootstrap(bootstrap_deps_url
):
57 """Grab all the deps listed in the file at bootstrap_deps_url."""
58 bootstrap_txt
= urllib2
.urlopen(
59 BASE_URL
+ 'src/tools/telemetry_tools/telemetry_bootstrap.py').read()
60 bootstrap
= imp
.new_module('bootstrap')
61 exec bootstrap_txt
in bootstrap
.__dict
__
62 bootstrap
.DownloadDeps(BOOTSTRAP_BASE_PATH
, bootstrap_deps_url
)
65 def ListBootstrapDeps(base_path
, subdir
):
66 """List the deps required for telemetry."""
67 sys
.path
.append(os
.path
.join(base_path
, TELEMETRY_TOOLS_DIR
))
68 import telemetry_bootstrap
70 deps_file
= os
.path
.join(base_path
, subdir
, DEPS_FILE
)
71 return telemetry_bootstrap
.ListAllDepsPaths(deps_file
)
75 if not _GetBasePath():
76 _Bootstrap(BASE_URL
+ 'src/tools/perf/' + DEPS_FILE
)
78 new_base_path
= _GetBasePath()
79 new_perf_path
= os
.path
.join(new_base_path
, PERF_DIR
)
80 new_telemetry_path
= os
.path
.join(new_base_path
, TELEMETRY_DIR
)
82 if '--print-bootstrap-deps-cros' in sys
.argv
:
83 print ListBootstrapDeps(new_base_path
, CROS_DIR
)
86 if '--print-bootstrap-deps' in sys
.argv
:
87 print ListBootstrapDeps(new_base_path
, PERF_DIR
)
90 sys
.path
.append(new_perf_path
)
92 page_set_filenames
= page_sets
.GetAllPageSetFilenames()
94 old_benchmark_names
= {
95 "image_decoding_benchmark": "image_decoding",
96 "image_decoding_measurement": "image_decoding",
97 "loading_benchmark": "loading",
98 "loading_measurement": "loading",
99 "media_measurement": "media",
100 "memory_benchmark": "memory",
101 "memory_measurement": "memory",
102 "rasterize_and_record_benchmark": "rasterize_and_record",
103 "rasterize_and_record_measurement": "rasterize_and_record",
104 "robohornetpro": "robohornet_pro",
105 "scrolling_benchmark": "smoothness",
106 "smoothness_benchmark": "smoothness",
107 "smoothness_measurement": "smoothness",
108 "startup_benchmark": "startup_warm_blank_page",
109 "startup_measurement": "startup",
110 "tab_switching_measurement": "tab_switching",
113 sys
.path
.append(new_telemetry_path
)
114 from telemetry
.page
import page_measurement_runner
115 # There are bots that are hard-coded to run some specific named tests.
116 # Convert these to the current naming conventions by overriding them
118 class MeasurementRunner(page_measurement_runner
.PageMeasurementRunner
):
119 def GetModernizedTestName(self
, arg
):
120 if arg
not in old_benchmark_names
:
123 'An old name %s was given. Please use %s in the future.\n' % (
125 old_benchmark_names
.get(arg
)))
126 return old_benchmark_names
[arg
]
128 runner
= MeasurementRunner()
129 return runner
.Run(new_perf_path
, page_set_filenames
)
132 if __name__
== '__main__':