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

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

Issue 2890333002: Tab Switching Benchmark for ChromeOS (Closed)
Patch Set: Style fixes 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 # NOTE: When tab count is high, some tabs may be discarded, and the tab
15 # context would be invalidated. Avoid storing tab object for later use.
16 class CrosMultiTabStory(page_module.Page):
17 """Base class for multi-tab stories."""
18
19 def __init__(self, story_set, cros_remote, tabset_repeat=1):
20 super(CrosMultiTabStory, self).__init__(
21 shared_page_state_class=shared_page_state.SharedPageState,
22 page_set=story_set, name=self.NAME, url=self.URL)
23 self._cros_remote = cros_remote
24 self._tabset_repeat = tabset_repeat
25
26 def RunNavigateSteps(self, action_runner):
27 """Opening tabs and waiting for them to load."""
28 # As this story may run for a long time, adjusting screen off time to
29 # avoid screen off.
30 cros_utils.NoScreenOff(self._cros_remote)
31
32 tabs = action_runner.tab.browser.tabs
33
34 # No need to create the first tab as there is already one
35 # when the browser is ready.
36 url_list = self.URL_LIST * self._tabset_repeat
37 if url_list:
38 action_runner.Navigate(url_list[0])
39 for i, url in enumerate(url_list[1:]):
40 new_tab = tabs.New()
41 new_tab.action_runner.Navigate(url)
42 if i % 10 == 0:
43 print 'opening tab:', i
44
45 # Waiting for every tabs to be stable.
46 for i, url in enumerate(url_list):
47 try:
48 tabs[i].action_runner.WaitForNetworkQuiescence()
49 except py_utils.TimeoutException:
50 logging.info('WaitForNetworkQuiescence() timeout, url[%d]: %s',
51 i, url)
52 except exceptions.DevtoolsTargetCrashException:
53 logging.info('RunNavigateSteps: devtools context lost')
54
55 def RunPageInteractions(self, action_runner):
56 """Tab switching to each tabs."""
57 url_list = self.URL_LIST * self._tabset_repeat
58 browser = action_runner.tab.browser
59
60 total_tab_count = len(url_list)
61 live_tab_count = len(browser.tabs)
62 if live_tab_count != total_tab_count:
63 logging.warning('live tab: %d, tab discarded: %d',
64 live_tab_count, total_tab_count - live_tab_count)
65
66 with cros_utils.KeyboardEmulator(self._cros_remote) as keyboard:
67 for i in range(total_tab_count):
68 prev_histogram = cros_utils.GetTabSwitchHistogramRetry(browser)
69 keyboard.SwitchTab()
70 cros_utils.WaitTabSwitching(browser, prev_histogram)
71
72 if i % 10 == 0:
73 print 'switching tab:', i
74
75
76 class CrosMultiTabTypical24Story(CrosMultiTabStory):
77 """Multi-tab stories to test 24 typical webpages."""
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-'
99 'hope-you-never-believe'),
100 'http://www.imdb.com/title/tt0910970/',
101 'http://www.flickr.com/search/?q=monkeys&f=hp',
102 'http://money.cnn.com/',
103 'http://www.nationalgeographic.com/',
104 'http://premierleague.com',
105 'http://www.osubeavers.com/',
106 'http://walgreens.com',
107 'http://colorado.edu',
108 ('http://www.ticketmaster.com/JAY-Z-and-Justin-Timberlake-tickets/artist/'
109 '1837448?brand=none&tm_link=tm_homeA_rc_name2'),
110 # pylint: disable=line-too-long
111 'http://www.theverge.com/2013/3/5/4061684/inside-ted-the-smartest-bubble-i n-the-world',
112 'http://www.airbnb.com/',
113 'http://www.ign.com/',
114 # Why: Alexa health #25
115 'http://www.fda.gov',
116 ]
117 URL = URL_LIST[0]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698