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

Side by Side Diff: tools/perf/page_sets/system_health/single_page_stories.py

Issue 2118293002: Add benchmark that imitates news reading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: extract ClickLink Created 4 years, 5 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
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 logging
6 import sys 5 import sys
7 6
7 from page_sets.system_health import platforms
8 from page_sets.system_health import system_health_story
9
8 from page_sets.login_helpers import dropbox_login 10 from page_sets.login_helpers import dropbox_login
9 from page_sets.login_helpers import google_login 11 from page_sets.login_helpers import google_login
10 12
11 from telemetry.core import discover
12 from telemetry.page import page
13 13
14 14 class _SinglePageStory(system_health_story.SystemHealthStory):
15 _ALL_PLATFORMS = frozenset({'desktop', 'mobile'})
16 _DESKTOP_ONLY = frozenset({'desktop'})
17 _MOBILE_ONLY = frozenset({'mobile'})
18 _NO_PLATFORMS = frozenset()
19
20
21 _DUMP_WAIT_TIME = 3
22
23
24 class _SinglePageStory(page.Page):
25 """Abstract base class for single-page System Health user stories.""" 15 """Abstract base class for single-page System Health user stories."""
26 16 pass
27 # The full name of a single page story has the form CASE:GROUP:PAGE (e.g.
28 # 'load:search:google').
29 NAME = NotImplemented
30 URL = NotImplemented
31 SUPPORTED_PLATFORMS = _ALL_PLATFORMS
32
33 def __init__(self, story_set, take_memory_measurement):
34 case, group, _ = self.NAME.split(':')
35 super(_SinglePageStory, self).__init__(
36 page_set=story_set, name=self.NAME, url=self.URL,
37 credentials_path='../data/credentials.json',
38 grouping_keys={'case': case, 'group': group})
39 self._take_memory_measurement = take_memory_measurement
40
41 def _Measure(self, action_runner):
42 if not self._take_memory_measurement:
43 return
44 # TODO(petrcermak): This method is essentially the same as
45 # MemoryHealthPage._TakeMemoryMeasurement() in memory_health_story.py.
46 # Consider sharing the common code.
47 action_runner.Wait(_DUMP_WAIT_TIME)
48 action_runner.ForceGarbageCollection()
49 action_runner.Wait(_DUMP_WAIT_TIME)
50 tracing_controller = action_runner.tab.browser.platform.tracing_controller
51 if not tracing_controller.is_tracing_running:
52 return # Tracing is not running, e.g., when recording a WPR archive.
53 if not action_runner.tab.browser.DumpMemory():
54 logging.error('Unable to get a memory dump for %s.', self.name)
55
56 def _Login(self, action_runner):
57 pass
58
59 def _DidLoadDocument(self, action_runner):
60 pass
61
62 def RunNavigateSteps(self, action_runner):
63 self._Login(action_runner)
64 super(_SinglePageStory, self).RunNavigateSteps(action_runner)
65
66 def RunPageInteractions(self, action_runner):
67 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
68 self._DidLoadDocument(action_runner)
69 self._Measure(action_runner)
70 17
71 18
72 def IterAllStoryClasses(): 19 def IterAllStoryClasses():
73 # Sort the classes by their names so that their order is stable and 20 return system_health_story.IterAllStoryClasses(
74 # deterministic. 21 sys.modules[__name__], _SinglePageStory)
75 for unused_cls_name, cls in sorted(discover.DiscoverClassesInModule(
76 module=sys.modules[__name__],
77 base_class=_SinglePageStory,
78 index_by_class_name=True).iteritems()):
79 yield cls
80 22
81 23
82 ################################################################################ 24 ################################################################################
83 # Search and e-commerce. 25 # Search and e-commerce.
84 ################################################################################ 26 ################################################################################
85 27
86 28
87 class LoadGoogleStory(_SinglePageStory): 29 class LoadGoogleStory(_SinglePageStory):
88 NAME = 'load:search:google' 30 NAME = 'load:search:google'
89 URL = 'https://www.google.com/#hl=en&q=science' 31 URL = 'https://www.google.com/#hl=en&q=science'
(...skipping 10 matching lines...) Expand all
100 42
101 43
102 class LoadAmazonStory(_SinglePageStory): 44 class LoadAmazonStory(_SinglePageStory):
103 NAME = 'load:search:amazon' 45 NAME = 'load:search:amazon'
104 URL = 'https://www.amazon.com/s/?field-keywords=nexus' 46 URL = 'https://www.amazon.com/s/?field-keywords=nexus'
105 47
106 48
107 class LoadTaobaoDesktopStory(_SinglePageStory): 49 class LoadTaobaoDesktopStory(_SinglePageStory):
108 NAME = 'load:search:taobao' 50 NAME = 'load:search:taobao'
109 URL = 'https://world.taobao.com/' 51 URL = 'https://world.taobao.com/'
110 SUPPORTED_PLATFORMS = _DESKTOP_ONLY 52 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
111 53
112 54
113 class LoadTaobaoMobileStory(_SinglePageStory): 55 class LoadTaobaoMobileStory(_SinglePageStory):
114 NAME = 'load:search:taobao' 56 NAME = 'load:search:taobao'
115 # "ali_trackid" in the URL suppresses "Download app" interstitial. 57 # "ali_trackid" in the URL suppresses "Download app" interstitial.
116 URL = 'http://m.intl.taobao.com/?ali_trackid' 58 URL = 'http://m.intl.taobao.com/?ali_trackid'
117 SUPPORTED_PLATFORMS = _MOBILE_ONLY 59 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
118 60
119 61
120 class LoadYandexStory(_SinglePageStory): 62 class LoadYandexStory(_SinglePageStory):
121 NAME = 'load:search:yandex' 63 NAME = 'load:search:yandex'
122 URL = 'https://yandex.ru/touchsearch?text=science' 64 URL = 'https://yandex.ru/touchsearch?text=science'
123 65
124 66
125 class LoadEbayStory(_SinglePageStory): 67 class LoadEbayStory(_SinglePageStory):
126 NAME = 'load:search:ebay' 68 NAME = 'load:search:ebay'
127 # Redirects to the "http://" version. 69 # Redirects to the "http://" version.
(...skipping 16 matching lines...) Expand all
144 URL = 'https://www.twitter.com/justinbieber?skip_interstitial=true' 86 URL = 'https://www.twitter.com/justinbieber?skip_interstitial=true'
145 87
146 88
147 class LoadVkStory(_SinglePageStory): 89 class LoadVkStory(_SinglePageStory):
148 NAME = 'load:social:vk' 90 NAME = 'load:social:vk'
149 URL = 'https://vk.com/sbeatles' 91 URL = 'https://vk.com/sbeatles'
150 # Due to the deterministic date injected by WPR (February 2008), the cookie 92 # Due to the deterministic date injected by WPR (February 2008), the cookie
151 # set by https://vk.com immediately expires, so the page keeps refreshing 93 # set by https://vk.com immediately expires, so the page keeps refreshing
152 # indefinitely on mobile 94 # indefinitely on mobile
153 # (see https://github.com/chromium/web-page-replay/issues/71). 95 # (see https://github.com/chromium/web-page-replay/issues/71).
154 SUPPORTED_PLATFORMS = _DESKTOP_ONLY 96 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
155 97
156 98
157 class LoadInstagramStory(_SinglePageStory): 99 class LoadInstagramStory(_SinglePageStory):
158 NAME = 'load:social:instagram' 100 NAME = 'load:social:instagram'
159 URL = 'https://www.instagram.com/selenagomez/' 101 URL = 'https://www.instagram.com/selenagomez/'
160 102
161 103
162 class LoadPinterestStory(_SinglePageStory): 104 class LoadPinterestStory(_SinglePageStory):
163 NAME = 'load:social:pinterest' 105 NAME = 'load:social:pinterest'
164 URL = 'https://uk.pinterest.com/categories/popular/' 106 URL = 'https://uk.pinterest.com/categories/popular/'
(...skipping 12 matching lines...) Expand all
177 119
178 class LoadBbcStory(_SinglePageStory): 120 class LoadBbcStory(_SinglePageStory):
179 NAME = 'load:news:bbc' 121 NAME = 'load:news:bbc'
180 # Redirects to the "http://" version. 122 # Redirects to the "http://" version.
181 URL = 'https://www.bbc.co.uk/news/world-asia-china-36189636' 123 URL = 'https://www.bbc.co.uk/news/world-asia-china-36189636'
182 124
183 125
184 class LoadCnnStory(_SinglePageStory): 126 class LoadCnnStory(_SinglePageStory):
185 NAME = 'load:news:cnn' 127 NAME = 'load:news:cnn'
186 # Using "https://" shows "Your connection is not private". 128 # Using "https://" shows "Your connection is not private".
187 URL = ( 129 URL = 'http://edition.cnn.com'
188 'http://edition.cnn.com/2016/05/02/health/three-habitable-planets-earth-dw arf-star/index.html')
189 130
190 131
191 class LoadRedditDesktopStory(_SinglePageStory): 132 class LoadHackerNewsStory(_SinglePageStory):
192 NAME = 'load:news:reddit' 133 NAME = 'load:news:hackernews'
193 URL = ( 134 URL = 'https://news.ycombinator.com'
194 'https://www.reddit.com/r/AskReddit/comments/4hi90e/whats_your_best_weddin g_horror_story/')
195 SUPPORTED_PLATFORMS = _DESKTOP_ONLY
196 135
197 136
198 class LoadRedditMobileStory(_SinglePageStory): 137 class LoadNytimesDesktopStory(_SinglePageStory):
199 NAME = 'load:news:reddit' 138 NAME = 'load:news:nytimes'
200 URL = ( 139 URL = 'http://www.nytimes.com'
201 'https://m.reddit.com/r/AskReddit/comments/4hi90e/whats_your_best_wedding_ horror_story/') 140 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
202 SUPPORTED_PLATFORMS = _MOBILE_ONLY 141
142
143 class LoadNytimesMobileStory(_SinglePageStory):
144 NAME = 'load:news:nytimes'
145 URL = 'http://mobile.nytimes.com'
146 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
203 147
204 148
205 class LoadQqMobileStory(_SinglePageStory): 149 class LoadQqMobileStory(_SinglePageStory):
206 NAME = 'load:news:qq' 150 NAME = 'load:news:qq'
207 # Using "https://" hangs and shows "This site can't be reached". 151 # Using "https://" hangs and shows "This site can't be reached".
208 URL = 'http://news.qq.com/a/20160503/003186.htm' 152 URL = 'http://news.qq.com'
153
154
155 class LoadRedditDesktopStory(_SinglePageStory):
156 NAME = 'load:news:reddit'
157 URL = 'https://www.reddit.com/top/?sort=top&t=week'
158 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
159
160
161 class LoadRedditMobileStory(_SinglePageStory):
162 NAME = 'load:news:reddit'
163 URL = 'https://m.reddit.com/?sort=top&time=week'
164 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
209 165
210 166
211 class LoadSohuStory(_SinglePageStory): 167 class LoadSohuStory(_SinglePageStory):
212 NAME = 'load:news:sohu' 168 NAME = 'load:news:sohu'
213 # Using "https://" leads to missing images and scripts on mobile (due to 169 # Using "https://" leads to missing images and scripts on mobile (due to
214 # mixed content). 170 # mixed content).
215 URL = 'http://m.sohu.com/n/447433356/' 171 URL = 'http://m.sohu.com/n/447433356/'
216 # The desktop page (http://news.sohu.com/20160503/n447433356.shtml) almost 172 # The desktop page (http://news.sohu.com/20160503/n447433356.shtml) almost
217 # always fails to completely load due to 173 # always fails to completely load due to
218 # https://github.com/chromium/web-page-replay/issues/74. 174 # https://github.com/chromium/web-page-replay/issues/74.
219 SUPPORTED_PLATFORMS = _MOBILE_ONLY 175 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
176
177
178 class LoadWashingtonPostMobileStory(_SinglePageStory):
179 NAME = 'load:news:washingtonpost'
180 URL = 'https://www.washingtonpost.com/pwa'
181 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
182
183 def _DidLoadDocument(self, action_runner):
184 # Close the popup window.
185 action_runner.ClickElement(selector='.close')
220 186
221 187
222 class LoadWikipediaStory(_SinglePageStory): 188 class LoadWikipediaStory(_SinglePageStory):
223 NAME = 'load:news:wikipedia' 189 NAME = 'load:news:wikipedia'
224 URL = 'https://en.wikipedia.org/wiki/Science' 190 URL = 'https://en.wikipedia.org/wiki/Science'
225 191
226 192
227 ################################################################################ 193 ################################################################################
228 # Audio and video. 194 # Audio and video.
229 ################################################################################ 195 ################################################################################
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 245
280 class LoadDocsStory(_SinglePageStory): 246 class LoadDocsStory(_SinglePageStory):
281 NAME = 'load:tools:docs' 247 NAME = 'load:tools:docs'
282 URL = ( 248 URL = (
283 'https://docs.google.com/document/d/1GvzDP-tTLmJ0myRhUAfTYWs3ZUFilUICg8psN HyccwQ/edit?usp=sharing') 249 'https://docs.google.com/document/d/1GvzDP-tTLmJ0myRhUAfTYWs3ZUFilUICg8psN HyccwQ/edit?usp=sharing')
284 250
285 251
286 class _LoadGmailBaseStory(_SinglePageStory): 252 class _LoadGmailBaseStory(_SinglePageStory):
287 NAME = 'load:tools:gmail' 253 NAME = 'load:tools:gmail'
288 URL = 'https://mail.google.com/mail/' 254 URL = 'https://mail.google.com/mail/'
289 SUPPORTED_PLATFORMS = _NO_PLATFORMS 255 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
290 256
291 def _Login(self, action_runner): 257 def _Login(self, action_runner):
292 google_login.LoginGoogleAccount(action_runner, 'googletest', 258 google_login.LoginGoogleAccount(action_runner, 'googletest',
293 self.credentials_path) 259 self.credentials_path)
294 260
295 # Navigating to https://mail.google.com immediately leads to an infinite 261 # Navigating to https://mail.google.com immediately leads to an infinite
296 # redirection loop due to a bug in WPR (see 262 # redirection loop due to a bug in WPR (see
297 # https://github.com/chromium/web-page-replay/issues/70). We therefore first 263 # https://github.com/chromium/web-page-replay/issues/70). We therefore first
298 # navigate to a sub-URL to set up the session and hit the resulting 264 # navigate to a sub-URL to set up the session and hit the resulting
299 # redirection loop. Afterwards, we can safely navigate to 265 # redirection loop. Afterwards, we can safely navigate to
300 # https://mail.google.com. 266 # https://mail.google.com.
301 action_runner.Navigate( 267 action_runner.Navigate(
302 'https://mail.google.com/mail/mu/mp/872/trigger_redirection_loop') 268 'https://mail.google.com/mail/mu/mp/872/trigger_redirection_loop')
303 action_runner.tab.WaitForDocumentReadyStateToBeComplete() 269 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
304 270
305 271
306 class LoadGmailDesktopStory(_LoadGmailBaseStory): 272 class LoadGmailDesktopStory(_LoadGmailBaseStory):
307 SUPPORTED_PLATFORMS = _DESKTOP_ONLY 273 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
308 274
309 def _DidLoadDocument(self, action_runner): 275 def _DidLoadDocument(self, action_runner):
310 # Wait until the UI loads. 276 # Wait until the UI loads.
311 action_runner.WaitForJavaScriptCondition( 277 action_runner.WaitForJavaScriptCondition(
312 'document.getElementById("loading").style.display === "none"') 278 'document.getElementById("loading").style.display === "none"')
313 279
314 class LoadGmailMobileStory(_LoadGmailBaseStory): 280 class LoadGmailMobileStory(_LoadGmailBaseStory):
315 SUPPORTED_PLATFORMS = _MOBILE_ONLY 281 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
316 282
317 def _DidLoadDocument(self, action_runner): 283 def _DidLoadDocument(self, action_runner):
318 # Close the "Get Inbox by Gmail" interstitial. 284 # Close the "Get Inbox by Gmail" interstitial.
319 action_runner.WaitForJavaScriptCondition( 285 action_runner.WaitForJavaScriptCondition(
320 'document.querySelector("#isppromo a") !== null') 286 'document.querySelector("#isppromo a") !== null')
321 action_runner.ExecuteJavaScript( 287 action_runner.ExecuteJavaScript(
322 'document.querySelector("#isppromo a").click()') 288 'document.querySelector("#isppromo a").click()')
323 # Wait until the UI loads. 289 # Wait until the UI loads.
324 action_runner.WaitForJavaScriptCondition( 290 action_runner.WaitForJavaScriptCondition(
325 'document.getElementById("apploadingdiv").style.height === "0px"') 291 'document.getElementById("apploadingdiv").style.height === "0px"')
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 # caption is displayed. 356 # caption is displayed.
391 action_runner.WaitForJavaScriptCondition( 357 action_runner.WaitForJavaScriptCondition(
392 'document.querySelector("#game canvas").style.background !== ""') 358 'document.querySelector("#game canvas").style.background !== ""')
393 359
394 360
395 class LoadMiniclipStory(_SinglePageStory): 361 class LoadMiniclipStory(_SinglePageStory):
396 NAME = 'load:games:miniclip' 362 NAME = 'load:games:miniclip'
397 # Using "https://" causes "404 Not Found" during WPR recording. 363 # Using "https://" causes "404 Not Found" during WPR recording.
398 URL = 'http://www.miniclip.com/games/en/' 364 URL = 'http://www.miniclip.com/games/en/'
399 # Desktop only (requires Flash). 365 # Desktop only (requires Flash).
400 SUPPORTED_PLATFORMS = _DESKTOP_ONLY 366 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
401 367
402 368
403 class LoadAlphabettyStory(_SinglePageStory): 369 class LoadAlphabettyStory(_SinglePageStory):
404 NAME = 'load:games:alphabetty' 370 NAME = 'load:games:alphabetty'
405 URL = 'https://king.com/play/alphabetty' 371 URL = 'https://king.com/play/alphabetty'
406 # Desktop only (requires Flash). 372 # Desktop only (requires Flash).
407 SUPPORTED_PLATFORMS = _DESKTOP_ONLY 373 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698