run_measurement revision a36e5920737c6adbddd3e43b760e5de8431db6e0
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. 5import imp 6import os 7import sys 8import urllib 9 10# Directory path in which to save bootstrap files. 11BOOTSTRAPPED_FILES_DIR = 'support/bootstrap_files' 12PERF_DIR = 'src/tools/perf' 13DEPS_FILE = 'bootstrap_deps' 14 15def BootstrapIfNeeded(module_name, module_path, module_deps_url): 16 """Ensures that the given module_name is available, grab from URL if not.""" 17 try: 18 imp.find_module(module_name) 19 return 20 except ImportError: 21 sys.path.append(os.path.join(os.path.dirname(__file__), 22 BOOTSTRAPPED_FILES_DIR, 23 module_path)) 24 try: 25 imp.find_module(module_name) 26 return 27 except ImportError: 28 bootstrap_txt = urllib.urlopen('http://src.chromium.org/viewvc/chrome/' + 29 'trunk/src/tools/telemetry_tools/' + 30 'telemetry_bootstrap.py').read() 31 bootstrap = imp.new_module('bootstrap') 32 exec bootstrap_txt in bootstrap.__dict__ 33 bootstrap.DownloadDepsURL(os.path.join(os.path.dirname(__file__), 34 BOOTSTRAPPED_FILES_DIR), 35 module_deps_url) 36 return 37 38def ListBootstrapDeps(): 39 """List the deps required for telemetry. 40 41 Returns: a list of telemetry deps. 42 """ 43 # Add telemetry_tools to sys.path for the import below 44 telemetry_tools_path = os.path.join(os.path.dirname(__file__), 45 os.pardir, 'telemetry_tools') 46 sys.path.append(telemetry_tools_path) 47 48 import perf_tools 49 import telemetry_bootstrap 50 deps_file = os.path.join(os.path.dirname(perf_tools.__file__), 51 DEPS_FILE) 52 return telemetry_bootstrap.ListAllDepsPaths(open(deps_file).read()) 53 54def main(): 55 BootstrapIfNeeded('perf_tools', PERF_DIR, 56 'http://src.chromium.org/viewvc/chrome/trunk/src/tools' 57 '/perf/perf_tools/' + DEPS_FILE) 58 59 # Add telemetry to sys.path for the import below 60 telemetry_path = os.path.join(os.path.dirname(__file__), 61 os.pardir, 'telemetry') 62 sys.path.append(telemetry_path) 63 64 if '--print-bootstrap-deps' in sys.argv: 65 print ListBootstrapDeps() 66 sys.exit(0) 67 68 from telemetry.page import page_measurement_runner 69 import page_sets 70 page_set_filenames = page_sets.GetAllPageSetFilenames() 71 72 old_benchmark_names = { 73 "image_decoding_benchmark": "image_decoding", 74 "image_decoding_measurement": "image_decoding", 75 "loading_benchmark": "loading", 76 "loading_measurement": "loading", 77 "media_measurement": "media", 78 "memory_benchmark": "memory", 79 "memory_measurement": "memory", 80 "rasterize_and_record_benchmark": "rasterize_and_record", 81 "rasterize_and_record_measurement": "rasterize_and_record", 82 "robohornetpro": "robohornet_pro", 83 "scrolling_benchmark": "smoothness", 84 "smoothness_benchmark": "smoothness", 85 "smoothness_measurement": "smoothness", 86 "startup_benchmark": "startup_warm", 87 "startup_measurement": "startup_warm", 88 "tab_switching_measurement": "tab_switching", 89 } 90 91 # There are bots that are hard-coded to run some specific named tests. 92 # Convert these to the current naming conventions by overriding them in the runner. 93 class MeasurementRunner(page_measurement_runner.PageMeasurementRunner): 94 def GetModernizedTestName(self, arg): 95 if arg not in old_benchmark_names: 96 return arg 97 sys.stderr.write( 98 'An old name %s was given. Please use %s in the future.\n' % ( 99 arg, 100 old_benchmark_names.get(arg))) 101 return old_benchmark_names[arg] 102 103 runner = MeasurementRunner() 104 sys.exit(runner.Run(os.path.dirname(__file__), page_set_filenames)) 105 106if __name__ == '__main__': 107 sys.exit(main()) 108