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

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

Issue 1663053006: perf: Add a power benchmark for pages with heavy ads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/benchmarks/smoothness.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
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 4
5 from page_sets import repeatable_synthesize_scroll_gesture_shared_state 5 from page_sets import repeatable_synthesize_scroll_gesture_shared_state
6 6
7 from telemetry.page import page as page_module 7 from telemetry.page import page as page_module
8 from telemetry import story 8 from telemetry import story
9 9
10 10
(...skipping 15 matching lines...) Expand all
26 'meta.name = "viewport";' 26 'meta.name = "viewport";'
27 'meta.content = "width=device-width";' 27 'meta.content = "width=device-width";'
28 'document.getElementsByTagName("head")[0].appendChild(meta);') 28 'document.getElementsByTagName("head")[0].appendChild(meta);')
29 action_runner.EvaluateJavaScript(viewport_js) 29 action_runner.EvaluateJavaScript(viewport_js)
30 30
31 def RunPageInteractions(self, action_runner): 31 def RunPageInteractions(self, action_runner):
32 with action_runner.CreateInteraction('ToughAd'): 32 with action_runner.CreateInteraction('ToughAd'):
33 action_runner.Wait(10) 33 action_runner.Wait(10)
34 34
35 35
36 class ScrollingPage(page_module.Page): 36 class AdPage(page_module.Page):
37 37
38 def __init__(self, url, page_set, make_javascript_deterministic=True, 38 def __init__(self, url, page_set, make_javascript_deterministic=True,
39 y_scroll_distance_multiplier=0.5, bidirectional_scroll=False, 39 y_scroll_distance_multiplier=0.5, bidirectional_scroll=False,
40 scroll=False,
40 wait_for_interactive_or_better=False): 41 wait_for_interactive_or_better=False):
41 super(ScrollingPage, self).__init__( 42 super(AdPage, self).__init__(
42 url=url, 43 url=url,
43 page_set=page_set, 44 page_set=page_set,
44 make_javascript_deterministic=make_javascript_deterministic, 45 make_javascript_deterministic=make_javascript_deterministic,
45 shared_page_state_class=( 46 shared_page_state_class=(
46 repeatable_synthesize_scroll_gesture_shared_state.\ 47 repeatable_synthesize_scroll_gesture_shared_state.\
47 RepeatableSynthesizeScrollGestureSharedState)) 48 RepeatableSynthesizeScrollGestureSharedState))
48 self._y_scroll_distance_multiplier = y_scroll_distance_multiplier 49 self._y_scroll_distance_multiplier = y_scroll_distance_multiplier
50 self._scroll = scroll
49 self._bidirectional_scroll = bidirectional_scroll 51 self._bidirectional_scroll = bidirectional_scroll
50 self._wait_for_interactive_or_better = wait_for_interactive_or_better 52 self._wait_for_interactive_or_better = wait_for_interactive_or_better
51 53
52 def RunNavigateSteps(self, action_runner): 54 def RunNavigateSteps(self, action_runner):
53 # Rewrite file urls to point to the replay server instead. 55 # Rewrite file urls to point to the replay server instead.
54 if self.is_file: 56 if self.is_file:
55 url = self.file_path_url_with_scheme 57 url = self.file_path_url_with_scheme
56 url = action_runner.tab.browser.platform.http_server.UrlOf( 58 url = action_runner.tab.browser.platform.http_server.UrlOf(
57 url[len('file://'):]) 59 url[len('file://'):])
58 else: 60 else:
(...skipping 11 matching lines...) Expand all
70 'document.body != null && ' 72 'document.body != null && '
71 'document.body.scrollHeight > window.innerHeight && ' 73 'document.body.scrollHeight > window.innerHeight && '
72 '!document.body.addEventListener("touchstart", function() {})') 74 '!document.body.addEventListener("touchstart", function() {})')
73 else: 75 else:
74 action_runner.WaitForJavaScriptCondition( 76 action_runner.WaitForJavaScriptCondition(
75 'document.body != null && ' 77 'document.body != null && '
76 'document.body.scrollHeight > window.innerHeight && ' 78 'document.body.scrollHeight > window.innerHeight && '
77 '!document.body.addEventListener("touchstart", function() {})') 79 '!document.body.addEventListener("touchstart", function() {})')
78 80
79 def RunPageInteractions(self, action_runner): 81 def RunPageInteractions(self, action_runner):
80 if self._bidirectional_scroll: 82 if not self._scroll:
83 with action_runner.CreateInteraction('ToughAd'):
84 action_runner.Wait(30)
85 elif self._bidirectional_scroll:
81 action_runner.RepeatableBrowserDrivenScroll( 86 action_runner.RepeatableBrowserDrivenScroll(
82 y_scroll_distance_ratio=self._y_scroll_distance_multiplier, 87 y_scroll_distance_ratio=self._y_scroll_distance_multiplier,
83 repeat_count=4) 88 repeat_count=4)
84 action_runner.RepeatableBrowserDrivenScroll( 89 action_runner.RepeatableBrowserDrivenScroll(
85 y_scroll_distance_ratio=-self._y_scroll_distance_multiplier * .5, 90 y_scroll_distance_ratio=-self._y_scroll_distance_multiplier * .5,
86 repeat_count=4) 91 repeat_count=4)
87 else: 92 else:
88 action_runner.RepeatableBrowserDrivenScroll( 93 action_runner.RepeatableBrowserDrivenScroll(
89 y_scroll_distance_ratio=self._y_scroll_distance_multiplier, 94 y_scroll_distance_ratio=self._y_scroll_distance_multiplier,
90 repeat_count=9) 95 repeat_count=9)
91 96
92 97
93 class ScrollingForbesPage(ScrollingPage): 98 class ForbesAdPage(AdPage):
94 99
95 def __init__(self, url, page_set, bidirectional_scroll=False): 100 def __init__(self, url, page_set, scroll=False, bidirectional_scroll=False):
96 # forbes.com uses a strange dynamic transform on the body element, 101 # forbes.com uses a strange dynamic transform on the body element,
97 # which occasionally causes us to try scrolling from outside the 102 # which occasionally causes us to try scrolling from outside the
98 # screen. Start at the very top of the viewport to avoid this. 103 # screen. Start at the very top of the viewport to avoid this.
99 super(ScrollingForbesPage, self).__init__( 104 super(ForbesAdPage, self).__init__(
100 url=url, page_set=page_set, make_javascript_deterministic=False, 105 url=url, page_set=page_set, make_javascript_deterministic=False,
106 scroll=scroll,
101 bidirectional_scroll=bidirectional_scroll, 107 bidirectional_scroll=bidirectional_scroll,
102 wait_for_interactive_or_better=True) 108 wait_for_interactive_or_better=True)
103 109
104 def RunNavigateSteps(self, action_runner): 110 def RunNavigateSteps(self, action_runner):
105 super(ScrollingForbesPage, self).RunNavigateSteps(action_runner) 111 super(ForbesAdPage, self).RunNavigateSteps(action_runner)
106 # Wait until the interstitial banner goes away. 112 # Wait until the interstitial banner goes away.
107 action_runner.WaitForJavaScriptCondition( 113 action_runner.WaitForJavaScriptCondition(
108 'window.location.pathname.indexOf("welcome") == -1') 114 'window.location.pathname.indexOf("welcome") == -1')
109 115
110 116
111 class ToughAdCasesPageSet(story.StorySet): 117 class SyntheticToughAdCasesPageSet(story.StorySet):
112 """Pages for measuring rendering performance with advertising content.""" 118 """Pages for measuring rendering performance with advertising content."""
113 119
114 def __init__(self): 120 def __init__(self):
115 super(ToughAdCasesPageSet, self).__init__( 121 super(SyntheticToughAdCasesPageSet, self).__init__(
116 archive_data_file='data/tough_ad_cases.json', 122 archive_data_file='data/tough_ad_cases.json',
117 cloud_storage_bucket=story.INTERNAL_BUCKET) 123 cloud_storage_bucket=story.INTERNAL_BUCKET)
118 124
119 base_url = 'http://localhost:8000' 125 base_url = 'http://localhost:8000'
120 126
121 # See go/swiffy-chrome-samples for how to add new pages here or how to 127 # See go/swiffy-chrome-samples for how to add new pages here or how to
122 # update the existing ones. 128 # update the existing ones.
123 swiffy_pages = [ 129 swiffy_pages = [
124 'CICAgICQ15a9NxDIARjIASgBMghBC1XuTk8ezw.swiffy72.html', 130 'CICAgICQ15a9NxDIARjIASgBMghBC1XuTk8ezw.swiffy72.html',
125 'shapes-CK7ptO3F8bi2KxDQAhiYAigBMgij6QBQtD2gyA.swiffy72.html', 131 'shapes-CK7ptO3F8bi2KxDQAhiYAigBMgij6QBQtD2gyA.swiffy72.html',
126 'CNP2xe_LmqPEKBCsAhj6ASgBMggnyMqth81h8Q.swiffy72.html', 132 'CNP2xe_LmqPEKBCsAhj6ASgBMggnyMqth81h8Q.swiffy72.html',
127 'clip-paths-CICAgMDO7Ye9-gEQ2AUYWigBMgjZxDii6aoK9w.swiffy72.html', 133 'clip-paths-CICAgMDO7Ye9-gEQ2AUYWigBMgjZxDii6aoK9w.swiffy72.html',
128 'filters-CNLa0t2T47qJ_wEQoAEY2AQoATIIFaIdc7VMBr4.swiffy72.html', 134 'filters-CNLa0t2T47qJ_wEQoAEY2AQoATIIFaIdc7VMBr4.swiffy72.html',
129 'shapes-CICAgMDO7cfIzwEQ1AMYPCgBMghqY8tqyRCArQ.swiffy72.html', 135 'shapes-CICAgMDO7cfIzwEQ1AMYPCgBMghqY8tqyRCArQ.swiffy72.html',
130 'CICAgIDQ2Pb-MxCsAhj6ASgBMgi5DLoSO0gPbQ.swiffy72.html', 136 'CICAgIDQ2Pb-MxCsAhj6ASgBMgi5DLoSO0gPbQ.swiffy72.html',
131 'CICAgKCN39CopQEQoAEY2AQoATIID59gK5hjjIg.swiffy72.html', 137 'CICAgKCN39CopQEQoAEY2AQoATIID59gK5hjjIg.swiffy72.html',
132 'CICAgKCNj4HgyAEQeBjYBCgBMgjQpPkOjyWNdw.1.swiffy72.html', 138 'CICAgKCNj4HgyAEQeBjYBCgBMgjQpPkOjyWNdw.1.swiffy72.html',
133 'clip-paths-CILZhLqO_-27bxB4GNgEKAEyCC46kMLBXnMT.swiffy72.html', 139 'clip-paths-CILZhLqO_-27bxB4GNgEKAEyCC46kMLBXnMT.swiffy72.html',
134 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swiffy72.html', 140 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swiffy72.html',
135 ] 141 ]
136 for page_name in swiffy_pages: 142 for page_name in swiffy_pages:
137 url = base_url + '/' + page_name 143 url = base_url + '/' + page_name
138 self.AddStory(SwiffyPage(url, self)) 144 self.AddStory(SwiffyPage(url, self))
139 145
140 146
141 class ToughWebglAdCasesPageSet(story.StorySet): 147 class SyntheticToughWebglAdCasesPageSet(story.StorySet):
142 """Pages for measuring rendering performance with WebGL ad content.""" 148 """Pages for measuring rendering performance with WebGL ad content."""
143 149
144 def __init__(self): 150 def __init__(self):
145 super(ToughWebglAdCasesPageSet, self).__init__( 151 super(SyntheticToughWebglAdCasesPageSet, self).__init__(
146 archive_data_file='data/tough_ad_cases.json', 152 archive_data_file='data/tough_ad_cases.json',
147 cloud_storage_bucket=story.INTERNAL_BUCKET) 153 cloud_storage_bucket=story.INTERNAL_BUCKET)
148 154
149 base_url = 'http://localhost:8000' 155 base_url = 'http://localhost:8000'
150 156
151 # See go/swiffy-chrome-samples for how to add new pages here or how to 157 # See go/swiffy-chrome-samples for how to add new pages here or how to
152 # update the existing ones. 158 # update the existing ones.
153 swiffy_pages = [ 159 swiffy_pages = [
154 'CICAgICQ15a9NxDIARjIASgBMghBC1XuTk8ezw.swf.webglbeta.html', 160 'CICAgICQ15a9NxDIARjIASgBMghBC1XuTk8ezw.swf.webglbeta.html',
155 'shapes-CK7ptO3F8bi2KxDQAhiYAigBMgij6QBQtD2gyA.swf.webglbeta.html', 161 'shapes-CK7ptO3F8bi2KxDQAhiYAigBMgij6QBQtD2gyA.swf.webglbeta.html',
156 'CNP2xe_LmqPEKBCsAhj6ASgBMggnyMqth81h8Q.swf.webglbeta.html', 162 'CNP2xe_LmqPEKBCsAhj6ASgBMggnyMqth81h8Q.swf.webglbeta.html',
157 'clip-paths-CICAgMDO7Ye9-gEQ2AUYWigBMgjZxDii6aoK9w.swf.webglbeta.html', 163 'clip-paths-CICAgMDO7Ye9-gEQ2AUYWigBMgjZxDii6aoK9w.swf.webglbeta.html',
158 'filters-CNLa0t2T47qJ_wEQoAEY2AQoATIIFaIdc7VMBr4.swf.webglbeta.html', 164 'filters-CNLa0t2T47qJ_wEQoAEY2AQoATIIFaIdc7VMBr4.swf.webglbeta.html',
159 'shapes-CICAgMDO7cfIzwEQ1AMYPCgBMghqY8tqyRCArQ.swf.webglbeta.html', 165 'shapes-CICAgMDO7cfIzwEQ1AMYPCgBMghqY8tqyRCArQ.swf.webglbeta.html',
160 'CICAgIDQ2Pb-MxCsAhj6ASgBMgi5DLoSO0gPbQ.swf.webglbeta.html', 166 'CICAgIDQ2Pb-MxCsAhj6ASgBMgi5DLoSO0gPbQ.swf.webglbeta.html',
161 'CICAgKCN39CopQEQoAEY2AQoATIID59gK5hjjIg.swf.webglbeta.html', 167 'CICAgKCN39CopQEQoAEY2AQoATIID59gK5hjjIg.swf.webglbeta.html',
162 'CICAgKCNj4HgyAEQeBjYBCgBMgjQpPkOjyWNdw.1.swf.webglbeta.html', 168 'CICAgKCNj4HgyAEQeBjYBCgBMgjQpPkOjyWNdw.1.swf.webglbeta.html',
163 'clip-paths-CILZhLqO_-27bxB4GNgEKAEyCC46kMLBXnMT.swf.webglbeta.html', 169 'clip-paths-CILZhLqO_-27bxB4GNgEKAEyCC46kMLBXnMT.swf.webglbeta.html',
164 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swf.webglbeta.html', 170 'CICAgMDOrcnRGRB4GNgEKAEyCP_ZBSfwUFsj.swf.webglbeta.html',
165 ] 171 ]
166 for page_name in swiffy_pages: 172 for page_name in swiffy_pages:
167 url = base_url + '/' + page_name 173 url = base_url + '/' + page_name
168 self.AddStory(SwiffyPage(url, self)) 174 self.AddStory(SwiffyPage(url, self))
169 175
170 176
177 class ToughAdCasesPageSet(story.StorySet):
178 """Pages for measuring performance with advertising content."""
179
180 def __init__(self, scroll=False, bidirectional_scroll=False):
181 super(ToughAdCasesPageSet, self).__init__(
182 archive_data_file='data/tough_ad_cases.json',
183 cloud_storage_bucket=story.INTERNAL_BUCKET)
184
185 self.AddStory(AdPage('file://tough_ad_cases/'
186 'swiffy_collection.html', self, make_javascript_deterministic=False,
187 y_scroll_distance_multiplier=0.25, scroll=scroll,
188 bidirectional_scroll=bidirectional_scroll))
189 self.AddStory(AdPage('file://tough_ad_cases/'
190 'swiffy_webgl_collection.html',
191 self, make_javascript_deterministic=False, scroll=scroll,
192 bidirectional_scroll=bidirectional_scroll))
193 self.AddStory(AdPage('http://www.latimes.com', self,
194 bidirectional_scroll=bidirectional_scroll, scroll=scroll,
195 wait_for_interactive_or_better=True))
196 self.AddStory(ForbesAdPage('http://www.forbes.com/sites/parmyolson/'
197 '2015/07/29/jana-mobile-data-facebook-internet-org/',
198 self, scroll=scroll, bidirectional_scroll=bidirectional_scroll))
199 self.AddStory(AdPage('http://androidcentral.com', self, scroll=scroll,
200 bidirectional_scroll=bidirectional_scroll,
201 wait_for_interactive_or_better=True))
202 self.AddStory(AdPage('http://mashable.com', self, scroll=scroll,
203 y_scroll_distance_multiplier=0.25,
204 bidirectional_scroll=bidirectional_scroll))
205 self.AddStory(AdPage('http://www.androidauthority.com/'
206 'reduce-data-use-turn-on-data-compression-in-chrome-630064/', self,
207 scroll=scroll, bidirectional_scroll=bidirectional_scroll))
208 self.AddStory(AdPage('http://www.cnn.com/2015/01/09/politics/',
209 'nebraska-keystone-pipeline/index.html', self, scroll=scroll,
210 bidirectional_scroll=bidirectional_scroll))
211 # Disabled: crbug.com/520509
212 #self.AddStory(AdPage('http://time.com/3977891/'
213 # 'donald-trump-debate-republican/', self, scroll=scroll,
214 # bidirectional_scroll=bidirectional_scroll))
215 self.AddStory(AdPage('http://www.theguardian.com/uk', self, scroll=scroll,
216 bidirectional_scroll=bidirectional_scroll))
217 self.AddStory(AdPage('http://m.tmz.com', self, scroll=scroll,
218 y_scroll_distance_multiplier=0.25,
219 bidirectional_scroll=bidirectional_scroll))
220 self.AddStory(AdPage('http://androidpolice.com', self, scroll=scroll,
221 bidirectional_scroll=bidirectional_scroll,
222 wait_for_interactive_or_better=True))
223
224
171 class ScrollingToughAdCasesPageSet(story.StorySet): 225 class ScrollingToughAdCasesPageSet(story.StorySet):
alex clarke (OOO till 29th) 2016/02/04 16:29:06 Is this inheritance right?
Sami 2016/02/04 16:30:16 Oops, fixed.
172 """Pages for measuring scrolling performance with advertising content.""" 226 """Pages for measuring scrolling performance with advertising content."""
173 227
174 def __init__(self, bidirectional_scroll=False): 228 def __init__(self):
175 super(ScrollingToughAdCasesPageSet, self).__init__( 229 super(ScrollingToughAdCasesPageSet, self).__init__(
176 archive_data_file='data/tough_ad_cases.json', 230 scroll=True)
177 cloud_storage_bucket=story.INTERNAL_BUCKET)
178
179 self.AddStory(ScrollingPage('file://tough_ad_cases/'
180 'swiffy_collection.html', self, make_javascript_deterministic=False,
181 y_scroll_distance_multiplier=0.25,
182 bidirectional_scroll=bidirectional_scroll))
183 self.AddStory(ScrollingPage('file://tough_ad_cases/'
184 'swiffy_webgl_collection.html',
185 self, make_javascript_deterministic=False,
186 bidirectional_scroll=bidirectional_scroll))
187 self.AddStory(ScrollingPage('http://www.latimes.com', self,
188 bidirectional_scroll=bidirectional_scroll,
189 wait_for_interactive_or_better=True))
190 self.AddStory(ScrollingForbesPage('http://www.forbes.com/sites/parmyolson/'
191 '2015/07/29/jana-mobile-data-facebook-internet-org/', self,
192 bidirectional_scroll=bidirectional_scroll))
193 self.AddStory(ScrollingPage('http://androidcentral.com', self,
194 bidirectional_scroll=bidirectional_scroll,
195 wait_for_interactive_or_better=True))
196 self.AddStory(ScrollingPage('http://mashable.com', self,
197 y_scroll_distance_multiplier=0.25,
198 bidirectional_scroll=bidirectional_scroll))
199 self.AddStory(ScrollingPage('http://www.androidauthority.com/'
200 'reduce-data-use-turn-on-data-compression-in-chrome-630064/', self,
201 bidirectional_scroll=bidirectional_scroll))
202 self.AddStory(ScrollingPage('http://www.cnn.com/2015/01/09/politics/'
203 'nebraska-keystone-pipeline/index.html', self,
204 bidirectional_scroll=bidirectional_scroll))
205 # Disabled: crbug.com/520509
206 #self.AddStory(ScrollingPage('http://time.com/3977891/'
207 # 'donald-trump-debate-republican/', self,
208 # bidirectional_scroll=bidirectional_scroll))
209 self.AddStory(ScrollingPage('http://www.theguardian.com/uk', self,
210 bidirectional_scroll=bidirectional_scroll))
211 self.AddStory(ScrollingPage('http://m.tmz.com', self,
212 y_scroll_distance_multiplier=0.25,
213 bidirectional_scroll=bidirectional_scroll))
214 self.AddStory(ScrollingPage('http://androidpolice.com', self,
215 bidirectional_scroll=bidirectional_scroll,
216 wait_for_interactive_or_better=True))
217 231
218 232
219 class BidirectionallyScrollingToughAdCasesPageSet(ScrollingToughAdCasesPageSet): 233 class BidirectionallyScrollingToughAdCasesPageSet(ToughAdCasesPageSet):
220 """Same as ScrollingAdCasesPageSet except we scroll in two directions.""" 234 """Same as ScrollingToughAdCasesPageSet except we scroll in two directions."""
221 235
222 def __init__(self): 236 def __init__(self):
223 super(BidirectionallyScrollingToughAdCasesPageSet, self).__init__( 237 super(BidirectionallyScrollingToughAdCasesPageSet, self).__init__(
224 bidirectional_scroll=True) 238 bidirectional_scroll=True)
OLDNEW
« no previous file with comments | « tools/perf/benchmarks/smoothness.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698