Refactor SnapSizer now that the --ash-multiple-snap-window-widths flag no longer...
[chromium-blink-merge.git] / tools / perf / run_measurement
blob52f730441b7d6ab9830272437091b639b5887297
1 #!/usr/bin/env python
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.
6 import imp
7 import os
8 import sys
9 import urllib2
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')
27 def _GetBasePath():
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.
33 Returns:
34 The path containing the src/ directory, or None if no checkout is found.
35 """
36 module_name = 'telemetry'
37 module_path = TELEMETRY_DIR
39 try:
40 paths = [os.path.join(CHECKOUT_BASE_PATH, module_path)]
41 imp.find_module(module_name, paths)
42 return CHECKOUT_BASE_PATH
43 except ImportError:
44 raise Exception('Unnable to compute base path')
46 def ListBootstrapDeps(base_path, subdir):
47 """List the deps required for telemetry."""
48 sys.path.append(os.path.join(base_path, TELEMETRY_TOOLS_DIR))
49 import telemetry_bootstrap
51 deps_file = os.path.join(base_path, subdir, DEPS_FILE)
52 return telemetry_bootstrap.ListAllDepsPaths(deps_file)
55 def Main():
56 new_base_path = _GetBasePath()
57 new_perf_path = os.path.join(new_base_path, PERF_DIR)
58 new_telemetry_path = os.path.join(new_base_path, TELEMETRY_DIR)
60 if '--print-bootstrap-deps-cros' in sys.argv:
61 print ListBootstrapDeps(new_base_path, CROS_DIR)
62 return 0
64 old_benchmark_names = {
65 "image_decoding_benchmark": "image_decoding",
66 "image_decoding_measurement": "image_decoding",
67 "loading_benchmark": "loading",
68 "loading_measurement": "loading",
69 "media_measurement": "media",
70 "memory_benchmark": "memory",
71 "memory_measurement": "memory",
72 "rasterize_and_record_benchmark": "rasterize_and_record",
73 "rasterize_and_record_measurement": "rasterize_and_record",
74 "robohornetpro": "robohornet_pro",
75 "scrolling_benchmark": "smoothness",
76 "smoothness_benchmark": "smoothness",
77 "smoothness_measurement": "smoothness",
78 "startup_benchmark": "startup_warm_blank_page",
79 "startup_measurement": "startup",
80 "tab_switching_measurement": "tab_switching",
83 sys.path.append(new_telemetry_path)
84 from telemetry.page import page_measurement_runner
85 from telemetry.core import environment
86 # There are bots that are hard-coded to run some specific named tests.
87 # Convert these to the current naming conventions by overriding them
88 # in the runner.
89 class MeasurementRunner(page_measurement_runner.PageMeasurementRunner):
90 def GetModernizedTestName(self, arg):
91 if arg not in old_benchmark_names:
92 return arg
93 sys.stderr.write(
94 'An old name %s was given. Please use %s in the future.\n' % (
95 arg,
96 old_benchmark_names.get(arg)))
97 return old_benchmark_names[arg]
99 runner = MeasurementRunner()
100 env = environment.Environment([new_perf_path])
101 return runner.Run(env)
104 if __name__ == '__main__':
105 sys.exit(Main())