NSS: {EC,RSA}PrivateKey shouldn't call crypto::GetPublicNSSKeySlot or GetPrivateNSSKe...
[chromium-blink-merge.git] / tools / perf / run_measurement
blob7877041ce16be1965a6dc16ee118d85ad99eb423
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.
5 import imp
6 import os
7 import sys
8 import urllib
10 # Directory path in which to save bootstrap files.
11 BOOTSTRAPPED_FILES_DIR = 'support/bootstrap_files'
12 PERF_DIR = 'src/tools/perf'
13 DEPS_FILE = 'bootstrap_deps'
14 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
16 def BootstrapIfNeeded(module_name, module_path, module_deps_url):
17 """Ensures that the given module_name is available, grab from URL if not."""
18 try:
19 imp.find_module(module_name)
20 return
21 except ImportError:
22 sys.path.append(os.path.join(BASE_DIR, BOOTSTRAPPED_FILES_DIR, module_path))
23 try:
24 imp.find_module(module_name)
25 return
26 except ImportError:
27 bootstrap_txt = urllib.urlopen('http://src.chromium.org/chrome/' +
28 'trunk/src/tools/telemetry_tools/' +
29 'telemetry_bootstrap.py').read()
30 bootstrap = imp.new_module('bootstrap')
31 exec bootstrap_txt in bootstrap.__dict__
32 bootstrap.DownloadDepsURL(os.path.join(BASE_DIR, BOOTSTRAPPED_FILES_DIR),
33 module_deps_url)
34 return
36 def ListBootstrapDeps():
37 """List the deps required for telemetry.
39 Returns: a list of telemetry deps.
40 """
41 # Add telemetry_tools to sys.path for the import below
42 telemetry_tools_path = os.path.join(BASE_DIR, os.pardir, 'telemetry_tools')
43 sys.path.append(telemetry_tools_path)
45 import perf_tools
46 import telemetry_bootstrap
47 deps_file = os.path.join(os.path.dirname(perf_tools.__file__), DEPS_FILE)
48 return telemetry_bootstrap.ListAllDepsPaths(open(deps_file).read())
50 def main():
51 BootstrapIfNeeded('perf_tools', PERF_DIR,
52 'http://src.chromium.org/chrome/trunk/src/tools'
53 '/perf/perf_tools/' + DEPS_FILE)
55 # Add telemetry to sys.path for the import below
56 telemetry_path = os.path.join(BASE_DIR, os.pardir, 'telemetry')
57 sys.path.append(telemetry_path)
59 if '--print-bootstrap-deps' in sys.argv:
60 print ListBootstrapDeps()
61 sys.exit(0)
63 from telemetry.page import page_measurement_runner
64 import page_sets
65 page_set_filenames = page_sets.GetAllPageSetFilenames()
67 old_benchmark_names = {
68 "image_decoding_benchmark": "image_decoding",
69 "image_decoding_measurement": "image_decoding",
70 "loading_benchmark": "loading",
71 "loading_measurement": "loading",
72 "media_measurement": "media",
73 "memory_benchmark": "memory",
74 "memory_measurement": "memory",
75 "rasterize_and_record_benchmark": "rasterize_and_record",
76 "rasterize_and_record_measurement": "rasterize_and_record",
77 "robohornetpro": "robohornet_pro",
78 "scrolling_benchmark": "smoothness",
79 "smoothness_benchmark": "smoothness",
80 "smoothness_measurement": "smoothness",
81 "startup_benchmark": "startup_warm_blank_page",
82 "startup_measurement": "startup",
83 "tab_switching_measurement": "tab_switching",
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 sys.exit(runner.Run(BASE_DIR, page_set_filenames))
102 if __name__ == '__main__':
103 sys.exit(main())