Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: tools/perf/benchmarks/blink_perf.py

Issue 736653002: [Pywebsocket PerformanceTests 2/2] Add blink_perf.pywebsocket (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Override shared_page_state. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/perf/benchmarks/pywebsocket_server.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
8 from telemetry.core import util 9 from telemetry.core import util
9 from telemetry import page as page_module 10 from telemetry import page as page_module
10 from telemetry.page import page_set 11 from telemetry.page import page_set
11 from telemetry.page import page_test 12 from telemetry.page import page_test
13 from telemetry.page import shared_page_state
12 from telemetry.value import list_of_scalar_values 14 from telemetry.value import list_of_scalar_values
13 15
14 16
15 BLINK_PERF_BASE_DIR = os.path.join(util.GetChromiumSrcDir(), 17 BLINK_PERF_BASE_DIR = os.path.join(util.GetChromiumSrcDir(),
16 'third_party', 'WebKit', 'PerformanceTests') 18 'third_party', 'WebKit', 'PerformanceTests')
17 SKIPPED_FILE = os.path.join(BLINK_PERF_BASE_DIR, 'Skipped') 19 SKIPPED_FILE = os.path.join(BLINK_PERF_BASE_DIR, 'Skipped')
18 20
19 21
20 def CreatePageSetFromPath(path, skipped_file): 22 def CreatePageSetFromPath(
23 path, skipped_file,
24 shared_page_state_class=shared_page_state.SharedPageState):
21 assert os.path.exists(path) 25 assert os.path.exists(path)
22 26
23 page_urls = [] 27 page_urls = []
24 serving_dirs = set() 28 serving_dirs = set()
25 29
26 def _AddPage(path): 30 def _AddPage(path):
27 if not path.endswith('.html'): 31 if not path.endswith('.html'):
28 return 32 return
29 if '../' in open(path, 'r').read(): 33 if '../' in open(path, 'r').read():
30 # If the page looks like it references its parent dir, include it. 34 # If the page looks like it references its parent dir, include it.
(...skipping 19 matching lines...) Expand all
50 line = line.strip() 54 line = line.strip()
51 if line and not line.startswith('#'): 55 if line and not line.startswith('#'):
52 skipped_path = os.path.join(os.path.dirname(skipped_file), line) 56 skipped_path = os.path.join(os.path.dirname(skipped_file), line)
53 skipped.append(skipped_path.replace('/', os.sep)) 57 skipped.append(skipped_path.replace('/', os.sep))
54 _AddDir(path, tuple(skipped)) 58 _AddDir(path, tuple(skipped))
55 else: 59 else:
56 _AddPage(path) 60 _AddPage(path)
57 ps = page_set.PageSet(file_path=os.getcwd()+os.sep, 61 ps = page_set.PageSet(file_path=os.getcwd()+os.sep,
58 serving_dirs=serving_dirs) 62 serving_dirs=serving_dirs)
59 for url in page_urls: 63 for url in page_urls:
60 ps.AddUserStory(page_module.Page(url, ps, ps.base_dir)) 64 ps.AddUserStory(page_module.Page(
65 url, ps, ps.base_dir, shared_page_state_class=shared_page_state_class))
61 return ps 66 return ps
62 67
63 68
64 class _BlinkPerfMeasurement(page_test.PageTest): 69 class _BlinkPerfMeasurement(page_test.PageTest):
65 """Tuns a blink performance test and reports the results.""" 70 """Tuns a blink performance test and reports the results."""
66 def __init__(self): 71 def __init__(self):
67 super(_BlinkPerfMeasurement, self).__init__() 72 super(_BlinkPerfMeasurement, self).__init__()
68 with open(os.path.join(os.path.dirname(__file__), 73 with open(os.path.join(os.path.dirname(__file__),
69 'blink_perf.js'), 'r') as f: 74 'blink_perf.js'), 'r') as f:
70 self._blink_perf_js = f.read() 75 self._blink_perf_js = f.read()
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 self._blink_perf_js += '\nwindow.fullFrameMeasurement = true;' 112 self._blink_perf_js += '\nwindow.fullFrameMeasurement = true;'
108 113
109 def CustomizeBrowserOptions(self, options): 114 def CustomizeBrowserOptions(self, options):
110 super(_BlinkPerfFullFrameMeasurement, self).CustomizeBrowserOptions( 115 super(_BlinkPerfFullFrameMeasurement, self).CustomizeBrowserOptions(
111 options) 116 options)
112 # Full layout measurement needs content_shell with internals testing API. 117 # Full layout measurement needs content_shell with internals testing API.
113 assert 'content-shell' in options.browser_type 118 assert 'content-shell' in options.browser_type
114 options.AppendExtraBrowserArgs(['--expose-internals-for-testing']) 119 options.AppendExtraBrowserArgs(['--expose-internals-for-testing'])
115 120
116 121
122 class _BlinkPerfPywebsocketMeasurement(_BlinkPerfMeasurement):
123 def CustomizeBrowserOptions(self, options):
124 super(_BlinkPerfPywebsocketMeasurement, self).CustomizeBrowserOptions(
125 options)
126 # Cross-origin accesses are needed to run benchmarks spanning two servers,
127 # the Telemetry's HTTP server and the pywebsocket server.
128 options.AppendExtraBrowserArgs(['--disable-web-security'])
129
130
131 class _SharedPywebsocketPageState(shared_page_state.SharedPageState):
132 """Runs a pywebsocket server."""
133 def WillRunUserStory(self, page):
134 super(_SharedPywebsocketPageState, self).WillRunUserStory(page)
135
136 # Start a pywebsocket server if not already running.
137 if not self.browser.GetRunningLocalServer(
138 pywebsocket_server.PywebsocketServer, None):
nednguyen 2015/04/06 17:34:02 Can you explain why we need this check?
hiroshige 2015/04/08 07:47:25 This is to avoid multiple instances of pywebsocket
nednguyen 2015/04/08 15:08:26 https://code.google.com/p/chromium/codesearch#chro
aiolos (Not reviewing) 2015/04/08 17:32:56 +1. You should only have logic that should be run
hiroshige 2015/04/09 09:11:42 Done (I'm not sure this is correct way to get plat
139 self.browser.StartLocalServer(pywebsocket_server.PywebsocketServer())
140
141
117 class BlinkPerfAnimation(benchmark.Benchmark): 142 class BlinkPerfAnimation(benchmark.Benchmark):
118 tag = 'animation' 143 tag = 'animation'
119 test = _BlinkPerfMeasurement 144 test = _BlinkPerfMeasurement
120 145
121 @classmethod 146 @classmethod
122 def Name(cls): 147 def Name(cls):
123 return 'blink_perf.animation' 148 return 'blink_perf.animation'
124 149
125 def CreatePageSet(self, options): 150 def CreatePageSet(self, options):
126 path = os.path.join(BLINK_PERF_BASE_DIR, 'Animation') 151 path = os.path.join(BLINK_PERF_BASE_DIR, 'Animation')
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 tag = 'xml_http_request' 324 tag = 'xml_http_request'
300 test = _BlinkPerfMeasurement 325 test = _BlinkPerfMeasurement
301 326
302 @classmethod 327 @classmethod
303 def Name(cls): 328 def Name(cls):
304 return 'blink_perf.xml_http_request' 329 return 'blink_perf.xml_http_request'
305 330
306 def CreatePageSet(self, options): 331 def CreatePageSet(self, options):
307 path = os.path.join(BLINK_PERF_BASE_DIR, 'XMLHttpRequest') 332 path = os.path.join(BLINK_PERF_BASE_DIR, 'XMLHttpRequest')
308 return CreatePageSetFromPath(path, SKIPPED_FILE) 333 return CreatePageSetFromPath(path, SKIPPED_FILE)
334
335
336 class BlinkPerfPywebsocket(benchmark.Benchmark):
337 tag = 'pywebsocket'
338 test = _BlinkPerfPywebsocketMeasurement
339
340 @classmethod
341 def Name(cls):
342 return 'blink_perf.pywebsocket'
343
344 def CreatePageSet(self, options):
345 path = os.path.join(BLINK_PERF_BASE_DIR, 'Pywebsocket')
346 return CreatePageSetFromPath(path, SKIPPED_FILE,
347 shared_page_state_class=_SharedPywebsocketPageState)
OLDNEW
« no previous file with comments | « no previous file | tools/perf/benchmarks/pywebsocket_server.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698