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

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

Issue 2706483003: Add Multi-tab System Health Story (Closed)
Patch Set: Refactoring Benchmark TabSwitching Created 3 years, 10 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
« no previous file with comments | « tools/perf/measurements/tab_switching_unittest.py ('k') | 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
(Empty)
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
3 # found in the LICENSE file.
4
5 import json
6 import py_utils
7
8 from telemetry.page import page as page_module
9 from telemetry.page import shared_page_state
10 from telemetry import story
11 from telemetry.value import histogram_util
12
13
14 class MultiTabStory(page_module.Page):
15 def __init__(self, page_set, urls_list):
16 super(MultiTabStory, self).__init__(url=urls_list[0], page_set=page_set,
17 credentials_path='data/credentials.json',
18 shared_page_state_class=shared_page_state.SharedDesktopPageState)
19 self._urls = urls_list
20 self._tabs = None
21 self._prev_histogram = None
22
23 @classmethod
24 def _GetTabSwitchHistogram(cls, tab_to_switch):
25 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration'
26 histogram_type = histogram_util.BROWSER_HISTOGRAM
27 return histogram_util.GetHistogram(
28 histogram_type, histogram_name, tab_to_switch)
29
30 def _WaitTabSwitchComplete(self, tab_to_switch):
31 def _IsDone():
32 # pylint: disable=W0640
33 cur_histogram = self._GetTabSwitchHistogram(tab_to_switch)
34 diff_histogram = histogram_util.SubtractHistogram(
35 cur_histogram, self._prev_histogram)
36 # TODO(deanliao): Add SubtractHistogramRawValue to process histogram
37 # object instead of JSON string.
38 diff_histogram_count = json.loads(diff_histogram).get('count', 0)
39 return diff_histogram_count > 0
40 py_utils.WaitFor(_IsDone, 30)
41
42 # We need to get histogram again instead of getting cur_histogram as
43 # variables modified inside inner function cannot be retrieved. However,
44 # inner function can see external scope's variables.
45 self._prev_histogram = self._GetTabSwitchHistogram(tab_to_switch)
46
47 def RunNavigateSteps(self, action_runner):
48 super(MultiTabStory, self).RunNavigateSteps(action_runner)
49
50 # create all tabs
51
52 browser = action_runner.tab.browser
53 # create tabs
54 self._tabs = [action_runner.tab]
55
56 for i in range(1, len(self._urls)):
57 new_tab = browser.tabs.New()
58 self._tabs.append(new_tab)
59 new_tab.action_runner.Navigate(self._urls[i])
60
61 for i in range(len(self._urls)):
62 py_utils.WaitFor(self._tabs[i].HasReachedQuiescence, 30)
63
64 def RunPageInteractions(self, action_runner):
65 # get initial histogram
66 self._prev_histogram = self._GetTabSwitchHistogram(self._tabs[-1])
67
68 # tab switching
69 for i in range(len(self._tabs)):
70 self._tabs[i].Activate()
71 self._WaitTabSwitchComplete(self._tabs[i])
72
73
74 class MultiTabTypical24StorySet(story.StorySet):
75 """ Pages designed to represent the median, not highly optimized web """
76 def __init__(self):
77 super(MultiTabTypical24StorySet, self).__init__(
78 archive_data_file='data/typical_25.json',
79 cloud_storage_bucket=story.PARTNER_BUCKET)
80
81 urls_list = [
82 # Why: Alexa games #48
83 'http://www.nick.com/games',
84 # Why: Alexa sports #45
85 'http://www.rei.com/',
86 # Why: Alexa sports #50
87 'http://www.fifa.com/',
88 # Why: Alexa shopping #41
89 'http://www.gamestop.com/ps3',
90 # Why: Alexa news #55
91 ('http://www.economist.com/news/science-and-technology/21573529-small-'
92 'models-cosmic-phenomena-are-shedding-light-real-thing-how-build'),
93 # Why: Alexa news #67
94 'http://www.theonion.com',
95 'http://arstechnica.com/',
96 # Why: Alexa home #10
97 'http://allrecipes.com/Recipe/Pull-Apart-Hot-Cross-Buns/Detail.aspx',
98 'http://www.html5rocks.com/en/',
99 'http://www.mlb.com/',
100 'http://gawker.com/5939683/based-on-a-true-story-is-a-rotten-lie-i-hope-yo u-never-believe',
101 'http://www.imdb.com/title/tt0910970/',
102 'http://www.flickr.com/search/?q=monkeys&f=hp',
103 'http://money.cnn.com/',
104 'http://www.nationalgeographic.com/',
105 'http://premierleague.com',
106 'http://www.osubeavers.com/',
107 'http://walgreens.com',
108 'http://colorado.edu',
109 ('http://www.ticketmaster.com/JAY-Z-and-Justin-Timberlake-tickets/artist/'
110 '1837448?brand=none&tm_link=tm_homeA_rc_name2'),
111 # pylint: disable=line-too-long
112 'http://www.theverge.com/2013/3/5/4061684/inside-ted-the-smartest-bubble-i n-the-world',
113 'http://www.airbnb.com/',
114 'http://www.ign.com/',
115 # Why: Alexa health #25
116 'http://www.fda.gov',
117 ]
118 self.AddStory(MultiTabStory(self, urls_list))
119
120
121 class MultiTabFiveBlankPagesStorySet(story.StorySet):
122 def __init__(self):
123 super(MultiTabFiveBlankPagesStorySet, self).__init__()
124 # archive_data_file='data/typical_25.json',
125 # cloud_storage_bucket=story.PARTNER_BUCKET)
126
127 urls_list = [
128 'file://blank_page/blank_page.html',
129 'file://blank_page/blank_page.html',
130 'file://blank_page/blank_page.html',
131 'file://blank_page/blank_page.html',
132 'file://blank_page/blank_page.html',
133 #'about:blank',
134 ]
135 self.AddStory(MultiTabStory(self, urls_list))
136
137
138 class MultiTabTop10StorySet(story.StorySet):
139 def __init__(self):
140 super(MultiTabTop10StorySet, self).__init__(
141 archive_data_file='data/top_10.json',
142 cloud_storage_bucket=story.PARTNER_BUCKET)
143
144 urls_list = [
145 'https://www.google.com/#hl=en&q=barack+obama',
146 #'https://mail.google.com/mail/',
147 'https://www.google.com/calendar/',
148 'http://www.youtube.com',
149 'https://www.facebook.com/barackobama',
150 'http://en.wikipedia.org/wiki/Wikipedia',
151 'http://www.amazon.com',
152 'http://www.yahoo.com/',
153 'http://www.bing.com/',
154 'http://www.ask.com/'
155 ]
156 self.AddStory(MultiTabStory(self, urls_list))
157
158
159 class MultiTabToughImageCasesStorySet(story.StorySet):
160 def __init__(self):
161 super(MultiTabToughImageCasesStorySet, self).__init__()
162
163 urls_list = [
164 'http://www.free-pictures-photos.com/aviation/airplane-306.jpg',
165 ('http://upload.wikimedia.org/wikipedia/commons/c/cb/'
166 'General_history%2C_Alaska_Yukon_Pacific_Exposition%'
167 '2C_fully_illustrated_-_meet_me_in_Seattle_1909_-_Page_78.jpg')
168 ]
169 self.AddStory(MultiTabStory(self, urls_list))
170
171
172 class MultiTabToughEnergyCasesStorySet(story.StorySet):
173 def __init__(self):
174 super(MultiTabToughEnergyCasesStorySet, self).__init__(
175 archive_data_file='data/tough_energy_cases.json',
176 cloud_storage_bucket=story.PARTNER_BUCKET)
177
178 urls_list = [
179 'http://codepen.io/testificate364/debug/nrbDc',
180 'http://codepen.io/testificate364/debug/fhKCg',
181 'http://codepen.io/testificate364/debug/paJhg',
182 'http://codepen.io/testificate364/debug/yaosK',
183 'http://codepen.io/testificate364/debug/DLbxg',
184 'http://codepen.io/testificate364/debug/kFvpd',
185 'http://codepen.io/testificate364/debug/lEhyw',
186 'http://codepen.io/testificate364/debug/zhgBD',
187 'http://codepen.io/testificate364/debug/jetyn',
188 'http://codepen.io/testificate364/debug/Kvdxs',
189 'http://codepen.io/testificate364/debug/lJAiH',
190 'http://codepen.io/testificate364/debug/EFceH',
191 'http://codepen.io/testificate364/debug/slBue',
192 'http://codepen.io/testificate364/debug/HdIgr',
193 ]
194 self.AddStory(MultiTabStory(self, urls_list))
OLDNEW
« no previous file with comments | « tools/perf/measurements/tab_switching_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698