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

Side by Side Diff: tools/perf/page_sets/top_25.py

Issue 650293007: Refactor top_25 so only page class with custom Run.. logic is defined (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 from telemetry.page import page as page_module 4 from telemetry.page import page as page_module
5 from telemetry.page import page_set as page_set_module 5 from telemetry.page import page_set as page_set_module
6 6
7 7
8 def _GetCurrentLocation(action_runner): 8 def _GetCurrentLocation(action_runner):
9 return action_runner.EvaluateJavaScript('document.location.href') 9 return action_runner.EvaluateJavaScript('document.location.href')
10 10
11 11
12 def _WaitForLocationChange(action_runner, old_href): 12 def _WaitForLocationChange(action_runner, old_href):
13 action_runner.WaitForJavaScriptCondition( 13 action_runner.WaitForJavaScriptCondition(
14 'document.location.href != "%s"' % old_href) 14 'document.location.href != "%s"' % old_href)
15 15
16 16
17 class Top25Page(page_module.Page): 17 class Top25Page(page_module.Page):
18 18
19 def __init__(self, url, page_set, name=''): 19 def __init__(self, url, page_set, name='', credentials=None):
20 super(Top25Page, self).__init__( 20 super(Top25Page, self).__init__(
21 url=url, page_set=page_set, name=name, 21 url=url, page_set=page_set, name=name,
22 credentials_path='data/credentials.json') 22 credentials_path='data/credentials.json')
23 self.user_agent_type = 'desktop' 23 self.user_agent_type = 'desktop'
24 self.archive_data_file = 'data/top_25.json' 24 self.archive_data_file = 'data/top_25.json'
25 self.credentials = credentials
25 26
26 def RunSmoothness(self, action_runner): 27 def RunSmoothness(self, action_runner):
27 interaction = action_runner.BeginGestureInteraction( 28 interaction = action_runner.BeginGestureInteraction(
28 'ScrollAction', is_smooth=True) 29 'ScrollAction', is_smooth=True)
29 action_runner.ScrollPage() 30 action_runner.ScrollPage()
30 interaction.End() 31 interaction.End()
31 32
32 def RunRepaint(self, action_runner): 33 def RunRepaint(self, action_runner):
33 action_runner.RepaintContinuously(seconds=5) 34 action_runner.RepaintContinuously(seconds=5)
34 35
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 })();''') 103 })();''')
103 action_runner.Wait(1) 104 action_runner.Wait(1)
104 105
105 def RunSmoothness(self, action_runner): 106 def RunSmoothness(self, action_runner):
106 interaction = action_runner.BeginGestureInteraction( 107 interaction = action_runner.BeginGestureInteraction(
107 'ScrollAction', is_smooth=True) 108 'ScrollAction', is_smooth=True)
108 action_runner.ScrollElement(selector='#scrolltimedeventswk') 109 action_runner.ScrollElement(selector='#scrolltimedeventswk')
109 interaction.End() 110 interaction.End()
110 111
111 112
112 class GoogleImageSearchPage(Top25Page):
113
114 """ Why: tough image case; top google properties """
115
116 def __init__(self, page_set):
117 super(GoogleImageSearchPage, self).__init__(
118 url='https://www.google.com/search?q=cats&tbm=isch',
119 page_set=page_set)
120
121 self.credentials = 'google'
122
123
124 class GoogleDocPage(Top25Page): 113 class GoogleDocPage(Top25Page):
125 114
126 """ Why: productivity, top google properties; Sample doc in the link """ 115 """ Why: productivity, top google properties; Sample doc in the link """
127 116
128 def __init__(self, page_set): 117 def __init__(self, page_set):
129 super(GoogleDocPage, self).__init__( 118 super(GoogleDocPage, self).__init__(
130 # pylint: disable=C0301 119 # pylint: disable=C0301
131 url='https://docs.google.com/document/d/1X-IKNjtEnx-WW5JIKRLsyhz5sbsat3mfT pAPUSX3_s4/view', 120 url='https://docs.google.com/document/d/1X-IKNjtEnx-WW5JIKRLsyhz5sbsat3mfT pAPUSX3_s4/view',
132 page_set=page_set, 121 page_set=page_set,
133 name='Docs (1 open document tab)') 122 name='Docs (1 open document tab)')
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 action_runner.NavigateToPage(self) 222 action_runner.NavigateToPage(self)
234 action_runner.WaitForElement(text='About') 223 action_runner.WaitForElement(text='About')
235 224
236 def RunSmoothness(self, action_runner): 225 def RunSmoothness(self, action_runner):
237 interaction = action_runner.BeginGestureInteraction( 226 interaction = action_runner.BeginGestureInteraction(
238 'ScrollAction', is_smooth=True) 227 'ScrollAction', is_smooth=True)
239 action_runner.ScrollPage() 228 action_runner.ScrollPage()
240 interaction.End() 229 interaction.End()
241 230
242 231
243 class LinkedinPage(Top25Page):
244 232
245 """ Why: #12 (Alexa global),Public profile """
246
247 def __init__(self, page_set):
248 super(LinkedinPage, self).__init__(
249 url='http://www.linkedin.com/in/linustorvalds',
250 page_set=page_set,
251 name='LinkedIn')
252
253
254 class WikipediaPage(Top25Page):
255
256 """ Why: #6 (Alexa) most visited worldwide,Picked an interesting page """
257
258 def __init__(self, page_set):
259 super(WikipediaPage, self).__init__(
260 url='http://en.wikipedia.org/wiki/Wikipedia',
261 page_set=page_set,
262 name='Wikipedia (1 tab)')
263 233
264 234
265 class TwitterPage(Top25Page): 235 class TwitterPage(Top25Page):
266 236
267 """ Why: #8 (Alexa global),Picked an interesting page """ 237 """ Why: #8 (Alexa global),Picked an interesting page """
268 238
269 def __init__(self, page_set): 239 def __init__(self, page_set):
270 super(TwitterPage, self).__init__( 240 super(TwitterPage, self).__init__(
271 url='https://twitter.com/katyperry', 241 url='https://twitter.com/katyperry',
272 page_set=page_set, 242 page_set=page_set,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 page_set=page_set, 280 page_set=page_set,
311 name='ESPN') 281 name='ESPN')
312 282
313 def RunSmoothness(self, action_runner): 283 def RunSmoothness(self, action_runner):
314 interaction = action_runner.BeginGestureInteraction( 284 interaction = action_runner.BeginGestureInteraction(
315 'ScrollAction', is_smooth=True) 285 'ScrollAction', is_smooth=True)
316 action_runner.ScrollPage(left_start_ratio=0.1) 286 action_runner.ScrollPage(left_start_ratio=0.1)
317 interaction.End() 287 interaction.End()
318 288
319 289
320 class WeatherDotComPage(Top25Page):
321
322 """ Why: #7 (Alexa news); #27 total time spent,Picked interesting page """
323
324 def __init__(self, page_set):
325 super(WeatherDotComPage, self).__init__(
326 # pylint: disable=C0301
327 url='http://www.weather.com/weather/right-now/Mountain+View+CA+94043',
328 page_set=page_set,
329 name='Weather.com')
330
331
332 class YahooGamesPage(Top25Page): 290 class YahooGamesPage(Top25Page):
333 291
334 """ Why: #1 games according to Alexa (with actual games in it) """ 292 """ Why: #1 games according to Alexa (with actual games in it) """
335 293
336 def __init__(self, page_set): 294 def __init__(self, page_set):
337 super(YahooGamesPage, self).__init__( 295 super(YahooGamesPage, self).__init__(
338 url='http://games.yahoo.com', 296 url='http://games.yahoo.com',
339 page_set=page_set) 297 page_set=page_set)
340 298
341 def RunNavigateSteps(self, action_runner): 299 def RunNavigateSteps(self, action_runner):
342 action_runner.NavigateToPage(self) 300 action_runner.NavigateToPage(self)
343 action_runner.Wait(2) 301 action_runner.Wait(2)
344 302
345 303
346 class Top25PageSet(page_set_module.PageSet): 304 class Top25PageSet(page_set_module.PageSet):
347 305
348 """ Pages hand-picked for 2012 CrOS scrolling tuning efforts. """ 306 """ Pages hand-picked for 2012 CrOS scrolling tuning efforts. """
349 307
350 def __init__(self): 308 def __init__(self):
351 super(Top25PageSet, self).__init__( 309 super(Top25PageSet, self).__init__(
352 user_agent_type='desktop', 310 user_agent_type='desktop',
353 archive_data_file='data/top_25.json', 311 archive_data_file='data/top_25.json',
354 bucket=page_set_module.PARTNER_BUCKET) 312 bucket=page_set_module.PARTNER_BUCKET)
355 313
356 self.AddPage(GoogleWebSearchPage(self)) 314 self.AddPage(GoogleWebSearchPage(self))
357 self.AddPage(GmailPage(self)) 315 self.AddPage(GmailPage(self))
358 self.AddPage(GoogleCalendarPage(self)) 316 self.AddPage(GoogleCalendarPage(self))
359 self.AddPage(GoogleImageSearchPage(self)) 317 # Why: tough image case; top google properties
318 self.AddPage(
319 Top25Page('https://www.google.com/search?q=cats&tbm=isch',
320 page_set=self, credentials='google'))
360 self.AddPage(GoogleDocPage(self)) 321 self.AddPage(GoogleDocPage(self))
361 self.AddPage(GooglePlusPage(self)) 322 self.AddPage(GooglePlusPage(self))
362 self.AddPage(YoutubePage(self)) 323 self.AddPage(YoutubePage(self))
363 self.AddPage(BlogspotPage(self)) 324 self.AddPage(BlogspotPage(self))
364 self.AddPage(WordpressPage(self)) 325 self.AddPage(WordpressPage(self))
365 self.AddPage(FacebookPage(self)) 326 self.AddPage(FacebookPage(self))
366 self.AddPage(LinkedinPage(self)) 327 # Why: #12 (Alexa global), Public profile.
367 self.AddPage(WikipediaPage(self)) 328 self.AddPage(
329 Top25Page(
330 'http://www.linkedin.com/in/linustorvalds', self, 'LinkedIn'))
ernstm 2014/10/27 21:30:04 to be consistent with the other pages: page_set=se
331 # Why: #6 (Alexa) most visited worldwide,Picked an interesting page
332 self.AddPage(
333 Top25Page(
334 'http://en.wikipedia.org/wiki/Wikipedia', page_set=self,
335 name='Wikipedia (1 tab)'))
368 self.AddPage(TwitterPage(self)) 336 self.AddPage(TwitterPage(self))
369 self.AddPage(PinterestPage(self)) 337 self.AddPage(PinterestPage(self))
370 self.AddPage(ESPNPage(self)) 338 self.AddPage(ESPNPage(self))
371 self.AddPage(WeatherDotComPage(self)) 339 # Why: #7 (Alexa news); #27 total time spent, picked interesting page.
340 self.AddPage(Top25Page(
341 url='http://www.weather.com/weather/right-now/Mountain+View+CA+94043',
342 page_set=self,
343 name='Weather.com'))
372 self.AddPage(YahooGamesPage(self)) 344 self.AddPage(YahooGamesPage(self))
373 345
374 other_urls = [ 346 other_urls = [
375 # Why: #1 news worldwide (Alexa global) 347 # Why: #1 news worldwide (Alexa global)
376 'http://news.yahoo.com', 348 'http://news.yahoo.com',
377 # Why: #2 news worldwide 349 # Why: #2 news worldwide
378 'http://www.cnn.com', 350 'http://www.cnn.com',
379 # Why: #1 world commerce website by visits; #3 commerce in the US by time 351 # Why: #1 world commerce website by visits; #3 commerce in the US by time
380 # spent 352 # spent
381 'http://www.amazon.com', 353 'http://www.amazon.com',
382 # Why: #1 commerce website by time spent by users in US 354 # Why: #1 commerce website by time spent by users in US
383 'http://www.ebay.com', 355 'http://www.ebay.com',
384 # Why: #1 Alexa recreation 356 # Why: #1 Alexa recreation
385 'http://booking.com', 357 'http://booking.com',
386 # Why: #1 Alexa reference 358 # Why: #1 Alexa reference
387 'http://answers.yahoo.com', 359 'http://answers.yahoo.com',
388 # Why: #1 Alexa sports 360 # Why: #1 Alexa sports
389 'http://sports.yahoo.com/', 361 'http://sports.yahoo.com/',
390 # Why: top tech blog 362 # Why: top tech blog
391 'http://techcrunch.com' 363 'http://techcrunch.com'
392 ] 364 ]
393 365
394 for url in other_urls: 366 for url in other_urls:
395 self.AddPage(Top25Page(url, self)) 367 self.AddPage(Top25Page(url, self))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698