Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 | 6 |
| 7 from benchmarks import pywebsocket_server | |
| 7 from telemetry import benchmark | 8 from telemetry import benchmark |
| 9 from telemetry.core import local_server | |
| 10 from telemetry.core import platform as platform_module | |
| 8 from telemetry.core import util | 11 from telemetry.core import util |
| 9 from telemetry import page as page_module | 12 from telemetry import page as page_module |
| 10 from telemetry.page import page_set | 13 from telemetry.page import page_set |
| 11 from telemetry.page import page_test | 14 from telemetry.page import page_test |
| 15 from telemetry.page import shared_page_state | |
| 12 from telemetry.value import list_of_scalar_values | 16 from telemetry.value import list_of_scalar_values |
| 13 | 17 |
| 14 | 18 |
| 15 BLINK_PERF_BASE_DIR = os.path.join(util.GetChromiumSrcDir(), | 19 BLINK_PERF_BASE_DIR = os.path.join(util.GetChromiumSrcDir(), |
| 16 'third_party', 'WebKit', 'PerformanceTests') | 20 'third_party', 'WebKit', 'PerformanceTests') |
| 17 SKIPPED_FILE = os.path.join(BLINK_PERF_BASE_DIR, 'Skipped') | 21 SKIPPED_FILE = os.path.join(BLINK_PERF_BASE_DIR, 'Skipped') |
| 18 | 22 |
| 19 | 23 |
| 20 def CreatePageSetFromPath(path, skipped_file): | 24 def CreatePageSetFromPath( |
| 25 path, skipped_file, | |
| 26 shared_page_state_class=shared_page_state.SharedPageState): | |
| 21 assert os.path.exists(path) | 27 assert os.path.exists(path) |
| 22 | 28 |
| 23 page_urls = [] | 29 page_urls = [] |
| 24 serving_dirs = set() | 30 serving_dirs = set() |
| 25 | 31 |
| 26 def _AddPage(path): | 32 def _AddPage(path): |
| 27 if not path.endswith('.html'): | 33 if not path.endswith('.html'): |
| 28 return | 34 return |
| 29 if '../' in open(path, 'r').read(): | 35 if '../' in open(path, 'r').read(): |
| 30 # If the page looks like it references its parent dir, include it. | 36 # If the page looks like it references its parent dir, include it. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 50 line = line.strip() | 56 line = line.strip() |
| 51 if line and not line.startswith('#'): | 57 if line and not line.startswith('#'): |
| 52 skipped_path = os.path.join(os.path.dirname(skipped_file), line) | 58 skipped_path = os.path.join(os.path.dirname(skipped_file), line) |
| 53 skipped.append(skipped_path.replace('/', os.sep)) | 59 skipped.append(skipped_path.replace('/', os.sep)) |
| 54 _AddDir(path, tuple(skipped)) | 60 _AddDir(path, tuple(skipped)) |
| 55 else: | 61 else: |
| 56 _AddPage(path) | 62 _AddPage(path) |
| 57 ps = page_set.PageSet(file_path=os.getcwd()+os.sep, | 63 ps = page_set.PageSet(file_path=os.getcwd()+os.sep, |
| 58 serving_dirs=serving_dirs) | 64 serving_dirs=serving_dirs) |
| 59 for url in page_urls: | 65 for url in page_urls: |
| 60 ps.AddUserStory(page_module.Page(url, ps, ps.base_dir)) | 66 ps.AddUserStory(page_module.Page( |
| 67 url, ps, ps.base_dir, shared_page_state_class=shared_page_state_class)) | |
| 61 return ps | 68 return ps |
| 62 | 69 |
| 63 | 70 |
| 64 class _BlinkPerfMeasurement(page_test.PageTest): | 71 class _BlinkPerfMeasurement(page_test.PageTest): |
| 65 """Tuns a blink performance test and reports the results.""" | 72 """Tuns a blink performance test and reports the results.""" |
| 66 def __init__(self): | 73 def __init__(self): |
| 67 super(_BlinkPerfMeasurement, self).__init__() | 74 super(_BlinkPerfMeasurement, self).__init__() |
| 68 with open(os.path.join(os.path.dirname(__file__), | 75 with open(os.path.join(os.path.dirname(__file__), |
| 69 'blink_perf.js'), 'r') as f: | 76 'blink_perf.js'), 'r') as f: |
| 70 self._blink_perf_js = f.read() | 77 self._blink_perf_js = f.read() |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 self._blink_perf_js += '\nwindow.fullFrameMeasurement = true;' | 114 self._blink_perf_js += '\nwindow.fullFrameMeasurement = true;' |
| 108 | 115 |
| 109 def CustomizeBrowserOptions(self, options): | 116 def CustomizeBrowserOptions(self, options): |
| 110 super(_BlinkPerfFullFrameMeasurement, self).CustomizeBrowserOptions( | 117 super(_BlinkPerfFullFrameMeasurement, self).CustomizeBrowserOptions( |
| 111 options) | 118 options) |
| 112 # Full layout measurement needs content_shell with internals testing API. | 119 # Full layout measurement needs content_shell with internals testing API. |
| 113 assert 'content-shell' in options.browser_type | 120 assert 'content-shell' in options.browser_type |
| 114 options.AppendExtraBrowserArgs(['--expose-internals-for-testing']) | 121 options.AppendExtraBrowserArgs(['--expose-internals-for-testing']) |
| 115 | 122 |
| 116 | 123 |
| 124 class _BlinkPerfPywebsocketMeasurement(_BlinkPerfMeasurement): | |
| 125 def CustomizeBrowserOptions(self, options): | |
| 126 super(_BlinkPerfPywebsocketMeasurement, self).CustomizeBrowserOptions( | |
| 127 options) | |
| 128 # Cross-origin accesses are needed to run benchmarks spanning two servers, | |
| 129 # the Telemetry's HTTP server and the pywebsocket server. | |
| 130 options.AppendExtraBrowserArgs(['--disable-web-security']) | |
| 131 | |
| 132 | |
| 133 class _SharedPywebsocketPageState(shared_page_state.SharedPageState): | |
| 134 """Runs a pywebsocket server.""" | |
| 135 def __init__(self, test, finder_options, user_story_set): | |
| 136 super(_SharedPywebsocketPageState, self).__init__( | |
| 137 test, finder_options, user_story_set) | |
| 138 platform = platform_module.GetHostPlatform() | |
| 139 backend = platform._platform_backend # pylint: disable=W0212 | |
|
nednguyen
2015/04/09 15:41:51
No don't do this, platform_backend is not a public
hiroshige
2015/04/23 08:41:57
Done.
| |
| 140 self._local_server_controller = local_server.LocalServerController( | |
| 141 backend) | |
| 142 self._local_server_controller.StartServer( | |
| 143 pywebsocket_server.PywebsocketServer()) | |
| 144 | |
| 145 def TearDownState(self, results): | |
| 146 super(_SharedPywebsocketPageState, self).TearDownState(results) | |
| 147 self._local_server_controller.Close() | |
| 148 | |
| 149 | |
| 117 class BlinkPerfAnimation(benchmark.Benchmark): | 150 class BlinkPerfAnimation(benchmark.Benchmark): |
| 118 tag = 'animation' | 151 tag = 'animation' |
| 119 test = _BlinkPerfMeasurement | 152 test = _BlinkPerfMeasurement |
| 120 | 153 |
| 121 @classmethod | 154 @classmethod |
| 122 def Name(cls): | 155 def Name(cls): |
| 123 return 'blink_perf.animation' | 156 return 'blink_perf.animation' |
| 124 | 157 |
| 125 def CreatePageSet(self, options): | 158 def CreatePageSet(self, options): |
| 126 path = os.path.join(BLINK_PERF_BASE_DIR, 'Animation') | 159 path = os.path.join(BLINK_PERF_BASE_DIR, 'Animation') |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 tag = 'xml_http_request' | 332 tag = 'xml_http_request' |
| 300 test = _BlinkPerfMeasurement | 333 test = _BlinkPerfMeasurement |
| 301 | 334 |
| 302 @classmethod | 335 @classmethod |
| 303 def Name(cls): | 336 def Name(cls): |
| 304 return 'blink_perf.xml_http_request' | 337 return 'blink_perf.xml_http_request' |
| 305 | 338 |
| 306 def CreatePageSet(self, options): | 339 def CreatePageSet(self, options): |
| 307 path = os.path.join(BLINK_PERF_BASE_DIR, 'XMLHttpRequest') | 340 path = os.path.join(BLINK_PERF_BASE_DIR, 'XMLHttpRequest') |
| 308 return CreatePageSetFromPath(path, SKIPPED_FILE) | 341 return CreatePageSetFromPath(path, SKIPPED_FILE) |
| 342 | |
| 343 | |
| 344 class BlinkPerfPywebsocket(benchmark.Benchmark): | |
| 345 tag = 'pywebsocket' | |
| 346 test = _BlinkPerfPywebsocketMeasurement | |
| 347 | |
| 348 @classmethod | |
| 349 def Name(cls): | |
| 350 return 'blink_perf.pywebsocket' | |
| 351 | |
| 352 def CreatePageSet(self, options): | |
| 353 path = os.path.join(BLINK_PERF_BASE_DIR, 'Pywebsocket') | |
| 354 return CreatePageSetFromPath(path, SKIPPED_FILE, | |
| 355 shared_page_state_class=_SharedPywebsocketPageState) | |
| OLD | NEW |