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

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

Issue 2092163002: [system-health] Generalize loading stories to single-page stories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase & address comments 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
(Empty)
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
3 # found in the LICENSE file.
4
5 import logging
6
7 from page_sets.login_helpers import dropbox_login
8 from page_sets.login_helpers import google_login
9
10 from telemetry import story
11 from telemetry.page import page as page_module
12
13
14 def _LogIntoGoogleAccount(action_runner, credentials_path):
15 google_login.LoginGoogleAccount(action_runner, 'googletest', credentials_path)
16
17
18 def _LogIntoGoogleAccountAndSetUpGmailSession(action_runner, credentials_path):
19 _LogIntoGoogleAccount(action_runner, credentials_path)
20
21 # Navigating to https://mail.google.com immediately leads to an infinite
22 # redirection loop due to a bug in WPR (see
23 # https://github.com/chromium/web-page-replay/issues/70). We therefore first
24 # navigate to a sub-URL to set up the session and hit the resulting
25 # redirection loop. Afterwards, we can safely navigate to
26 # https://mail.google.com.
27 action_runner.Navigate(
28 'https://mail.google.com/mail/mu/mp/872/trigger_redirection_loop')
29 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
30
31
32 def _LogIntoDropboxAccount(action_runner, credentials_path):
33 dropbox_login.LoginAccount(action_runner, 'dropbox', credentials_path)
34
35
36 def _CloseInboxInterstitialAndWaitUntilGmailReady(platform, action_runner):
37 if platform == 'desktop':
38 # Wait until the UI loads.
39 action_runner.WaitForJavaScriptCondition(
40 'document.getElementById("loading").style.display === "none"')
41 elif platform == 'mobile':
42 # Close the "Get Inbox by Gmail" interstitial.
43 action_runner.WaitForJavaScriptCondition(
44 'document.querySelector("#isppromo a") !== null')
45 action_runner.ExecuteJavaScript(
46 'document.querySelector("#isppromo a").click()')
47 # Wait until the UI loads.
48 action_runner.WaitForJavaScriptCondition(
49 'document.getElementById("apploadingdiv").style.height === "0px"')
50
51
52 def _WaitUntilBubblesReady(_, action_runner):
53 # The #logo element is removed right before the main menu is displayed.
54 action_runner.WaitForJavaScriptCondition(
55 'document.getElementById("logo") === null')
56
57
58 def _WaitUntilSpyChaseReady(_, action_runner):
59 # The background of the game canvas is set when the "Tap screen to play"
60 # caption is displayed.
61 action_runner.WaitForJavaScriptCondition(
62 'document.querySelector("#game canvas").style.background !== ""')
63
64
65 def _WaitUntilFlickrReady(_, action_runner):
66 # Wait until the 'Recently tagged' view loads.
67 action_runner.WaitForJavaScriptCondition('''
68 document.querySelector(
69 '.search-photos-everyone-trending-view .photo-list-view') !== null''')
70
71
72 class _PageSpec(object):
73
74 def __init__(self, name, url, login_hook=None, post_load_hook=None):
75 assert isinstance(url, (dict, str))
76 self._name = name
77 self._url = url
78 self._login_hook = login_hook
79 self._post_load_hook = post_load_hook
80
81 @property
82 def name(self):
83 return self._name
84
85 @property
86 def url(self):
87 return self._url
88
89 @property
90 def login_hook(self):
91 return self._login_hook
92
93 @property
94 def post_load_hook(self):
95 return self._post_load_hook
96
97
98 _SINGLE_PAGE_SPECS = {
99 # Search and e-commerce.
100 'search': [
101 _PageSpec(
102 name='google',
103 url='https://www.google.com/#hl=en&q=science'),
104 _PageSpec(
105 name='baidu',
106 url='https://www.baidu.com/s?word=google'),
107 _PageSpec(
108 name='yahoo',
109 url='https://search.yahoo.com/search;_ylt=?p=google'),
110 _PageSpec(
111 name='amazon',
112 url='https://www.amazon.com/s/?field-keywords=nexus'),
113 # "ali_trackid" in the URL suppresses "Download app" interstitial.
114 _PageSpec(
115 name='taobao',
116 url={'desktop': 'https://world.taobao.com/',
117 'mobile': 'http://m.intl.taobao.com/?ali_trackid'}),
118 _PageSpec(
119 name='yandex',
120 url='https://yandex.ru/touchsearch?text=science'),
121 # Redirects to the "http://" version.
122 _PageSpec(
123 name='ebay',
124 url='https://www.ebay.com/sch/i.html?_nkw=headphones'),
125 ],
126
127 # Social networks.
128 'social': [
129 # Using Facebook login often causes "404 Not Found" with WPR.
130 _PageSpec(
131 name='facebook',
132 url='https://www.facebook.com/rihanna'),
133 _PageSpec(
134 name='twitter',
135 url='https://www.twitter.com/justinbieber?skip_interstitial=true'),
136 # Due to the deterministic date injected by WPR (February 2008), the
137 # cookie set by https://vk.com immediately expires, so the page keeps
138 # refreshing indefinitely on mobile
139 # (see https://github.com/chromium/web-page-replay/issues/71).
140 _PageSpec(
141 name='vk',
142 url={'desktop': 'https://vk.com/sbeatles'}),
143 _PageSpec(
144 name='instagram',
145 url='https://www.instagram.com/selenagomez/'),
146 _PageSpec(
147 name='pinterest',
148 url='https://uk.pinterest.com/categories/popular/'),
149 # Redirects to the "http://" version.
150 _PageSpec(
151 name='tumblr',
152 url='https://50thousand.tumblr.com/'),
153 ],
154
155 # News, discussion and knowledge portals and blogs.
156 'news': [
157 # Redirects to the "http://" version.
158 _PageSpec(
159 name='bbc',
160 url='https://www.bbc.co.uk/news/world-asia-china-36189636'),
161 # Using "https://" shows "Your connection is not private".
162 _PageSpec(
163 name='cnn',
164 url=(
165 'http://edition.cnn.com/2016/05/02/health/three-habitable-planet s-earth-dwarf-star/index.html')),
166 _PageSpec(
167 name='reddit',
168 url={'desktop': (
169 'https://www.reddit.com/r/AskReddit/comments/4hi90e/whats_y our_best_wedding_horror_story/'),
170 'mobile': (
171 'https://m.reddit.com/r/AskReddit/comments/4hi90e/whats_you r_best_wedding_horror_story/')}),
172 # Using "https://" hangs and shows "This site can't be reached".
173 _PageSpec(
174 name='qq',
175 url='http://news.qq.com/a/20160503/003186.htm'),
176 # Using "https://" leads to missing images and scripts on mobile (due
177 # to mixed content). The desktop page
178 # (http://news.sohu.com/20160503/n447433356.shtml) almost always fails
179 # to completely load due to
180 # https://github.com/chromium/web-page-replay/issues/74.
181 _PageSpec(
182 name='sohu',
183 url={'mobile': 'http://m.sohu.com/n/447433356/'}),
184 _PageSpec(
185 name='wikipedia',
186 url='https://en.wikipedia.org/wiki/Science'),
187 ],
188
189 # Audio and video.
190 'media': [
191 # No way to disable autoplay on desktop.
192 _PageSpec(
193 name='youtube',
194 url='https://www.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false'),
195 # The side panel with related videos doesn't show on desktop due to
196 # https://github.com/chromium/web-page-replay/issues/74.
197 _PageSpec(
198 name='dailymotion',
199 url=(
200 'https://www.dailymotion.com/video/x489k7d_street-performer-show s-off-slinky-skills_fun?autoplay=false')),
201 _PageSpec(
202 name='google_images',
203 url='https://www.google.co.uk/search?tbm=isch&q=love'),
204 # No way to disable autoplay on desktop. Album artwork doesn't load due
205 # to https://github.com/chromium/web-page-replay/issues/73.
206 _PageSpec(
207 name='soundcloud',
208 url='https://soundcloud.com/lifeofdesiigner/desiigner-panda'),
209 _PageSpec(
210 name='9gag',
211 url='https://www.9gag.com/'),
212 _PageSpec(
213 name='flickr',
214 url='https://www.flickr.com/photos/tags/farm',
215 post_load_hook=_WaitUntilFlickrReady),
216 ],
217
218 # Online tools (documents, emails, storage, ...).
219 'tools': [
220 _PageSpec(
221 name='docs',
222 url=(
223 'https://docs.google.com/document/d/1GvzDP-tTLmJ0myRhUAfTYWs3ZUF ilUICg8psNHyccwQ/edit?usp=sharing')),
224 _PageSpec(
225 name='gmail',
226 url='https://mail.google.com/mail/',
227 login_hook=_LogIntoGoogleAccountAndSetUpGmailSession,
228 post_load_hook=_CloseInboxInterstitialAndWaitUntilGmailReady),
229 _PageSpec(
230 name='maps',
231 url='https://www.google.com/maps/place/London,+UK/'),
232 _PageSpec(
233 name='stackoverflow',
234 url=(
235 'https://stackoverflow.com/questions/36827659/compiling-an-appli cation-for-use-in-highly-radioactive-environments')),
236 _PageSpec(
237 name='dropbox',
238 url='https://www.dropbox.com',
239 login_hook=_LogIntoDropboxAccount),
240 _PageSpec(
241 name='weather',
242 url='https://weather.com/en-GB/weather/today/l/USCA0286:1:US'),
243 _PageSpec(
244 name='drive',
245 url='https://drive.google.com/drive/my-drive',
246 login_hook=_LogIntoGoogleAccount),
247 ],
248
249 # In-browser games (HTML5 and Flash).
250 'games': [
251 _PageSpec(
252 name='bubbles',
253 url=(
254 'https://games.cdn.famobi.com/html5games/s/smarty-bubbles/v010/? fg_domain=play.famobi.com&fg_uid=d8f24956-dc91-4902-9096-a46cb1353b6f&fg_pid=463 8e320-4444-4514-81c4-d80a8c662371&fg_beat=620'),
255 post_load_hook=_WaitUntilBubblesReady),
256 # Using "https://" hangs and shows "This site can't be reached".
257 _PageSpec(
258 name='lazors',
259 url='http://www8.games.mobi/games/html5/lazors/lazors.html'),
260 # Using "https://" shows "Your connection is not private".
261 _PageSpec(
262 name='spychase',
263 url='http://playstar.mobi/games/spychase/index.php',
264 post_load_hook=_WaitUntilSpyChaseReady),
265 # Desktop only (requires Flash). Using "https://" causes
266 # "404 Not Found" during WPR recording.
267 _PageSpec(
268 name='miniclip',
269 url={'desktop': 'http://www.miniclip.com/games/en/'}),
270 # Desktop only (requires Flash).
271 _PageSpec(
272 name='alphabetty',
273 url={'desktop': 'https://king.com/play/alphabetty'}),
274 ],
275 }
276
277
278 DUMP_WAIT_TIME = 3
279
280
281 class _LoadCase(page_module.Page):
282 """Generic System Health user story that loads a page and measures memory."""
283
284 def __init__(self, story_set, group, url, page_spec,
285 take_memory_measurement=True):
286 # For example, the name of the story for the |page_spec| with name
287 # 'example' from the 'sample' URL |group| will be 'load:sample:example'.
288 name = 'load:%s:%s' % (group, page_spec.name)
289 super(_LoadCase, self).__init__(
290 page_set=story_set, name=name, url=url,
291 credentials_path='../data/credentials.json',
292 grouping_keys={'case': 'load', 'group': group})
293 self._page_spec = page_spec
294 self._take_memory_measurement = take_memory_measurement
295
296 @property
297 def platform(self):
298 return self.story_set.PLATFORM
299
300 def _TakeMemoryMeasurement(self, action_runner):
301 # TODO(petrcermak): This method is essentially the same as
302 # MemoryHealthPage._TakeMemoryMeasurement() in memory_health_story.py.
303 # Consider sharing the common code.
304 action_runner.Wait(DUMP_WAIT_TIME)
305 action_runner.ForceGarbageCollection()
306 action_runner.Wait(DUMP_WAIT_TIME)
307 tracing_controller = action_runner.tab.browser.platform.tracing_controller
308 if not tracing_controller.is_tracing_running:
309 return # Tracing is not running, e.g., when recording a WPR archive.
310 if not action_runner.tab.browser.DumpMemory():
311 logging.error('Unable to get a memory dump for %s.', self.name)
312
313 def RunNavigateSteps(self, action_runner):
314 if self._page_spec.login_hook:
315 self._page_spec.login_hook(action_runner, self.credentials_path)
316 super(_LoadCase, self).RunNavigateSteps(action_runner)
317
318 def RunPageInteractions(self, action_runner):
319 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
320 if self._page_spec.post_load_hook:
321 self._page_spec.post_load_hook(self.platform, action_runner)
322 if self._take_memory_measurement:
323 self._TakeMemoryMeasurement(action_runner)
324
325 class _MemorySystemHealthStorySet(story.StorySet):
326 """User stories for the System Health Plan.
327
328 See https://goo.gl/Jek2NL.
329 """
330 PLATFORM = NotImplemented
331
332 def __init__(self, take_memory_measurement=True):
333 super(_MemorySystemHealthStorySet, self).__init__(
334 archive_data_file=('../data/memory_system_health_%s.json' %
335 self.PLATFORM),
336 cloud_storage_bucket=story.PARTNER_BUCKET)
337
338 for group_name, page_specs in _SINGLE_PAGE_SPECS.iteritems():
339 for page_spec in page_specs:
340 url = page_spec.url
341 if isinstance(url, dict):
342 url = url.get(self.PLATFORM)
343 if url is None:
344 continue # URL not supported on the platform.
345 self.AddStory(
346 _LoadCase(self, group_name, url, page_spec,
347 take_memory_measurement=take_memory_measurement))
348
349
350 class DesktopMemorySystemHealthStorySet(_MemorySystemHealthStorySet):
351 """Desktop user stories for Chrome Memory System Health Plan."""
352 PLATFORM = 'desktop'
353
354
355 class MobileMemorySystemHealthStorySet(_MemorySystemHealthStorySet):
356 """Mobile user stories for Chrome Memory System Health Plan."""
357 PLATFORM = 'mobile'
OLDNEW
« no previous file with comments | « tools/perf/benchmarks/system_health.py ('k') | tools/perf/page_sets/system_health/single_page_stories.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698