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

Side by Side Diff: tools/perf/contrib/cros_benchmarks/tab_switching_stories.py

Issue 2890333002: Tab Switching Benchmark for ChromeOS (Closed)
Patch Set: Tab Switching Benchmark for ChromeOS Created 3 years, 7 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 2017 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 py_utils
6 import logging
7
8 from telemetry.core import exceptions
9 from telemetry.page import page as page_module
10 from telemetry.page import shared_page_state
11 from contrib.cros_benchmarks import cros_utils
12
13
14 class CrosMultiTabSharedState(shared_page_state.SharedPageState):
15 def __init__(self, test, finder_options, story_set):
16 super(CrosMultiTabSharedState, self).__init__(test,finder_options,
17 story_set)
18 cros_utils.SetupKeyDispatch(finder_options.cros_remote)
19
20
21 # NOTE: When tab count is high, some tabs may be discarded, and the tab
22 # context would be invalidated. Avoid storing tab object for later use.
23 class CrosMultiTabStory(page_module.Page):
24 def __init__(self, story_set, tabset_repeat=1):
25 super(CrosMultiTabStory, self).__init__(
26 shared_page_state_class=CrosMultiTabSharedState, page_set=story_set,
27 name=self.NAME, url=self.URL)
28 self._tabset_repeat = tabset_repeat
29
30 def RunNavigateSteps(self, action_runner):
31 """Opening tabs and waiting for them to load."""
32 # As this story may run for a long time, adjusting screen off time to
33 # avoid screen off.
34 # pylint: disable=protected-access
35 cros_utils.NoScreenOff(action_runner.tab.browser._platform_backend)
36
37 tabs = action_runner.tab.browser.tabs
38
39 # No need to create the first tab as there is already one
40 # when the browser is ready.
41 url_list = self.URL_LIST * self._tabset_repeat
42 if url_list:
43 action_runner.Navigate(url_list[0])
44 for i, url in enumerate(url_list[1:]):
45 new_tab = tabs.New()
46 new_tab.action_runner.Navigate(url)
47 if i % 10 == 0:
48 print 'opening tab:', i
49
50 # Waiting for every tabs to be stable.
51 for i, url in enumerate(url_list):
52 try:
53 tabs[i].action_runner.WaitForNetworkQuiescence()
54 except py_utils.TimeoutException:
55 logging.info('WaitForNetworkQuiescence() timeout, url[%d]: %s'
56 % (i, url))
57 except exceptions.DevtoolsTargetCrashException:
58 logging.info('RunNavigateSteps: devtools context lost')
59
60 def RunPageInteractions(self, action_runner):
61 """Tab switching to each tabs."""
62 url_list = self.URL_LIST * self._tabset_repeat
63 browser = action_runner.tab.browser
64
65 total_tab_count = len(url_list)
66 live_tab_count = len(browser.tabs)
67 if live_tab_count != total_tab_count:
68 logging.warning('live tab: %d, tab discarded: %d',
69 live_tab_count, total_tab_count - live_tab_count)
70
71 for i in range(total_tab_count):
72 cros_utils.SwitchTab(browser)
73 if i % 10 == 0:
74 print 'switching tab:', i
75
76
77 class CrosMultiTabTypical24Story(CrosMultiTabStory):
78 NAME = 'cros_tab_switching_typical24'
79 URL_LIST = [
80 # Why: Alexa games #48
81 'http://www.nick.com/games',
82 # Why: Alexa sports #45
83 'http://www.rei.com/',
84 # Why: Alexa sports #50
85 'http://www.fifa.com/',
86 # Why: Alexa shopping #41
87 'http://www.gamestop.com/ps3',
88 # Why: Alexa news #55
89 ('http://www.economist.com/news/science-and-technology/21573529-small-'
90 'models-cosmic-phenomena-are-shedding-light-real-thing-how-build'),
91 # Why: Alexa news #67
92 'http://www.theonion.com',
93 'http://arstechnica.com/',
94 # Why: Alexa home #10
95 'http://allrecipes.com/Recipe/Pull-Apart-Hot-Cross-Buns/Detail.aspx',
96 'http://www.html5rocks.com/en/',
97 'http://www.mlb.com/',
98 'http://gawker.com/5939683/based-on-a-true-story-is-a-rotten-lie-i-hope-you- never-believe',
99 'http://www.imdb.com/title/tt0910970/',
100 'http://www.flickr.com/search/?q=monkeys&f=hp',
101 'http://money.cnn.com/',
102 'http://www.nationalgeographic.com/',
103 'http://premierleague.com',
104 'http://www.osubeavers.com/',
105 'http://walgreens.com',
106 'http://colorado.edu',
107 ('http://www.ticketmaster.com/JAY-Z-and-Justin-Timberlake-tickets/artist/'
108 '1837448?brand=none&tm_link=tm_homeA_rc_name2'),
109 # pylint: disable=line-too-long
110 'http://www.theverge.com/2013/3/5/4061684/inside-ted-the-smartest-bubble-in- the-world',
111 'http://www.airbnb.com/',
112 'http://www.ign.com/',
113 # Why: Alexa health #25
114 'http://www.fda.gov',
115 ]
116 URL = URL_LIST[0]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698