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 from telemetry
.page
import page
as page_module
5 from telemetry
.page
import page_set
as page_set_module
8 class ToughSchedulingCasesPage(page_module
.Page
):
10 def __init__(self
, url
, page_set
):
11 super(ToughSchedulingCasesPage
, self
).__init
__(
12 url
=url
, page_set
=page_set
, credentials_path
='data/credentials.json')
13 self
.user_agent_type
= 'mobile'
14 self
.archive_data_file
= 'data/tough_scheduling_cases.json'
16 def RunPageInteractions(self
, action_runner
):
17 interaction
= action_runner
.BeginGestureInteraction(
19 action_runner
.ScrollPage()
23 class Page1(ToughSchedulingCasesPage
):
25 """Why: Simulate oversubscribed main thread."""
27 def __init__(self
, page_set
):
28 super(Page1
, self
).__init
__(
29 url
='file://tough_scheduling_cases/simple_text_page.html?main_busy',
32 self
.synthetic_delays
= {'cc.BeginMainFrame': {'target_duration': 0.008}}
35 class Page2(ToughSchedulingCasesPage
):
37 """Why: Simulate oversubscribed main thread."""
39 def __init__(self
, page_set
):
40 super(Page2
, self
).__init
__(
41 # pylint: disable=C0301
42 url
='file://tough_scheduling_cases/simple_text_page.html?main_very_busy',
45 self
.synthetic_delays
= {'cc.BeginMainFrame': {'target_duration': 0.024}}
48 class Page3(ToughSchedulingCasesPage
):
50 """Why: Simulate a page with a a few graphics layers."""
52 def __init__(self
, page_set
):
53 super(Page3
, self
).__init
__(
54 # pylint: disable=C0301
55 url
='file://tough_scheduling_cases/simple_text_page.html?medium_layers',
58 self
.synthetic_delays
= {
59 'cc.DrawAndSwap': {'target_duration': 0.004},
60 'gpu.PresentingFrame': {'target_duration': 0.004},
61 'cc.BeginMainFrame': {'target_duration': 0.004}
65 class Page4(ToughSchedulingCasesPage
):
67 """Why: Simulate a page with many graphics layers."""
69 def __init__(self
, page_set
):
70 super(Page4
, self
).__init
__(
71 # pylint: disable=C0301
72 url
='file://tough_scheduling_cases/simple_text_page.html?many_layers',
75 self
.synthetic_delays
= {
76 'cc.DrawAndSwap': {'target_duration': 0.012},
77 'gpu.PresentingFrame': {'target_duration': 0.012},
78 'cc.BeginMainFrame': {'target_duration': 0.012}
82 class Page5(ToughSchedulingCasesPage
):
84 """Why: Simulate a page with expensive recording and rasterization."""
86 def __init__(self
, page_set
):
87 super(Page5
, self
).__init
__(
88 # pylint: disable=C0301
89 url
='file://tough_scheduling_cases/simple_text_page.html?medium_raster',
92 self
.synthetic_delays
= {
93 'cc.RasterRequiredForActivation': {'target_duration': 0.004},
94 'cc.BeginMainFrame': {'target_duration': 0.004},
95 'gpu.AsyncTexImage': {'target_duration': 0.004}
99 class Page6(ToughSchedulingCasesPage
):
101 """Why: Simulate a page with expensive recording and rasterization."""
103 def __init__(self
, page_set
):
104 super(Page6
, self
).__init
__(
105 # pylint: disable=C0301
106 url
='file://tough_scheduling_cases/simple_text_page.html?heavy_raster',
109 self
.synthetic_delays
= {
110 'cc.RasterRequiredForActivation': {'target_duration': 0.024},
111 'cc.BeginMainFrame': {'target_duration': 0.024},
112 'gpu.AsyncTexImage': {'target_duration': 0.024}
116 class Page7(ToughSchedulingCasesPage
):
118 """Why: Medium cost touch handler."""
120 def __init__(self
, page_set
):
121 super(Page7
, self
).__init
__(
122 # pylint: disable=C0301
123 url
='file://tough_scheduling_cases/touch_handler_scrolling.html?medium_handler',
126 self
.synthetic_delays
= {'blink.HandleInputEvent':
127 {'target_duration': 0.008}}
130 class Page8(ToughSchedulingCasesPage
):
132 """Why: Slow touch handler."""
134 def __init__(self
, page_set
):
135 super(Page8
, self
).__init
__(
136 # pylint: disable=C0301
137 url
='file://tough_scheduling_cases/touch_handler_scrolling.html?slow_handler',
140 self
.synthetic_delays
= {'blink.HandleInputEvent':
141 {'target_duration': 0.024}}
144 class Page9(ToughSchedulingCasesPage
):
146 """Why: Touch handler that often takes a long time."""
148 def __init__(self
, page_set
):
149 super(Page9
, self
).__init
__(
150 # pylint: disable=C0301
151 url
='file://tough_scheduling_cases/touch_handler_scrolling.html?janky_handler',
154 self
.synthetic_delays
= {'blink.HandleInputEvent':
155 {'target_duration': 0.024, 'mode': 'alternating'}
159 class Page10(ToughSchedulingCasesPage
):
161 """Why: Touch handler that occasionally takes a long time."""
163 def __init__(self
, page_set
):
164 super(Page10
, self
).__init
__(
165 # pylint: disable=C0301
166 url
='file://tough_scheduling_cases/touch_handler_scrolling.html?occasionally_janky_handler',
169 self
.synthetic_delays
= {'blink.HandleInputEvent':
170 {'target_duration': 0.024, 'mode': 'oneshot'}}
173 class Page11(ToughSchedulingCasesPage
):
175 """Why: Super expensive touch handler causes browser to scroll after a
178 def __init__(self
, page_set
):
179 super(Page11
, self
).__init
__(
180 # pylint: disable=C0301
181 url
='file://tough_scheduling_cases/touch_handler_scrolling.html?super_slow_handler',
184 self
.synthetic_delays
= {'blink.HandleInputEvent':
185 {'target_duration': 0.2}}
188 class Page12(ToughSchedulingCasesPage
):
190 """Why: Super expensive touch handler that only occupies a part of the page.
193 def __init__(self
, page_set
):
194 super(Page12
, self
).__init
__(
195 url
='file://tough_scheduling_cases/div_touch_handler.html',
198 self
.synthetic_delays
= {'blink.HandleInputEvent': {'target_duration': 0.2}}
201 class Page13(ToughSchedulingCasesPage
):
203 """Why: Test a moderately heavy requestAnimationFrame handler."""
205 def __init__(self
, page_set
):
206 super(Page13
, self
).__init
__(
207 url
='file://tough_scheduling_cases/raf.html?medium_handler',
210 self
.synthetic_delays
= {
211 'cc.RasterRequiredForActivation': {'target_duration': 0.004},
212 'cc.BeginMainFrame': {'target_duration': 0.004},
213 'gpu.AsyncTexImage': {'target_duration': 0.004}
217 class Page14(ToughSchedulingCasesPage
):
219 """Why: Test a moderately heavy requestAnimationFrame handler."""
221 def __init__(self
, page_set
):
222 super(Page14
, self
).__init
__(
223 url
='file://tough_scheduling_cases/raf.html?heavy_handler',
226 self
.synthetic_delays
= {
227 'cc.RasterRequiredForActivation': {'target_duration': 0.024},
228 'cc.BeginMainFrame': {'target_duration': 0.024},
229 'gpu.AsyncTexImage': {'target_duration': 0.024}
233 class Page15(ToughSchedulingCasesPage
):
235 """Why: Simulate a heavily GPU bound page."""
237 def __init__(self
, page_set
):
238 super(Page15
, self
).__init
__(
239 url
='file://tough_scheduling_cases/raf.html?gpu_bound',
242 self
.synthetic_delays
= {'gpu.PresentingFrame': {'target_duration': 0.1}}
245 class Page16(ToughSchedulingCasesPage
):
247 """Why: Test a requestAnimationFrame handler with a heavy first frame."""
249 def __init__(self
, page_set
):
250 super(Page16
, self
).__init
__(
251 url
='file://tough_scheduling_cases/raf.html?heavy_first_frame',
254 self
.synthetic_delays
= {'cc.BeginMainFrame': {'target_duration': 0.15,
258 class Page17(ToughSchedulingCasesPage
):
260 """Why: Medium stress test for the scheduler."""
262 def __init__(self
, page_set
):
263 super(Page17
, self
).__init
__(
264 url
='file://tough_scheduling_cases/raf_touch_animation.html?medium',
267 self
.synthetic_delays
= {
268 'cc.DrawAndSwap': {'target_duration': 0.004},
269 'cc.BeginMainFrame': {'target_duration': 0.004}
273 class Page18(ToughSchedulingCasesPage
):
275 """Why: Heavy stress test for the scheduler."""
277 def __init__(self
, page_set
):
278 super(Page18
, self
).__init
__(
279 url
='file://tough_scheduling_cases/raf_touch_animation.html?heavy',
282 self
.synthetic_delays
= {
283 'cc.DrawAndSwap': {'target_duration': 0.012},
284 'cc.BeginMainFrame': {'target_duration': 0.012}
288 class Page19(ToughSchedulingCasesPage
):
290 """Why: Both main and impl thread animating concurrently."""
292 def __init__(self
, page_set
):
293 super(Page19
, self
).__init
__(
294 url
='file://tough_scheduling_cases/split_animation.html',
297 def RunPageInteractions(self
, action_runner
):
298 action_runner
.Wait(3)
301 class Page20(ToughSchedulingCasesPage
):
303 """Why: Simple JS touch dragging."""
305 def __init__(self
, page_set
):
306 super(Page20
, self
).__init
__(
307 url
='file://tough_scheduling_cases/simple_touch_drag.html',
310 def RunPageInteractions(self
, action_runner
):
311 interaction
= action_runner
.BeginGestureInteraction(
313 action_runner
.ScrollElement(
317 speed_in_pixels_per_second
=150,
322 class EmptyTouchHandlerPage(ToughSchedulingCasesPage
):
324 """Why: Scrolling on a page with a touch handler that consumes no events but
327 def __init__(self
, name
, desktop
, slow_handler
, bounce
, page_set
):
328 super(EmptyTouchHandlerPage
, self
).__init
__(
329 url
='file://tough_scheduling_cases/empty_touch_handler' +
330 ('_desktop' if desktop
else '') + '.html?' + name
,
334 self
.synthetic_delays
= {
335 'blink.HandleInputEvent': {'target_duration': 0.2}
340 def RunPageInteractions(self
, action_runner
):
342 interaction
= action_runner
.BeginGestureInteraction(
343 'ScrollBounceAction')
344 action_runner
.ScrollBouncePage()
347 interaction
= action_runner
.BeginGestureInteraction(
349 # Speed and distance are tuned to run exactly as long as a scroll
351 action_runner
.ScrollPage(use_touch
=True, speed_in_pixels_per_second
=400,
356 class SynchronizedScrollOffsetPage(ToughSchedulingCasesPage
):
358 """Why: For measuring the latency of scroll-synchronized effects."""
360 def __init__(self
, page_set
):
361 super(SynchronizedScrollOffsetPage
, self
).__init
__(
362 url
='file://tough_scheduling_cases/sync_scroll_offset.html',
365 def RunPageInteractions(self
, action_runner
):
366 interaction
= action_runner
.BeginGestureInteraction(
367 'ScrollBounceAction')
368 action_runner
.ScrollBouncePage()
372 class SecondBatchJsPage(ToughSchedulingCasesPage
):
374 """Why: For testing dynamically loading a large batch of Javascript and
375 running a part of it in response to user input.
378 def __init__(self
, page_set
, variant
='medium'):
379 super(SecondBatchJsPage
, self
).__init
__(
380 url
='file://tough_scheduling_cases/second_batch_js.html?%s' % variant
,
383 def RunPageInteractions(self
, action_runner
):
384 # Do a dummy tap to warm up the synthetic tap code path.
385 action_runner
.TapElement(selector
='div[id="spinner"]')
386 # Begin the action immediately because we want the page to update smoothly
387 # even while resources are being loaded.
388 action_runner
.WaitForJavaScriptCondition('window.__ready !== undefined')
390 interaction
= action_runner
.BeginGestureInteraction('LoadAction')
391 action_runner
.ExecuteJavaScript('kickOffLoading()')
392 action_runner
.WaitForJavaScriptCondition('window.__ready')
393 # Click one second after the resources have finished loading.
394 action_runner
.Wait(1)
395 action_runner
.TapElement(selector
='input[id="run"]')
396 # Wait for the test to complete.
397 action_runner
.WaitForJavaScriptCondition('window.__finished')
401 class ToughSchedulingCasesPageSet(page_set_module
.PageSet
):
403 """Tough scheduler latency test cases."""
406 super(ToughSchedulingCasesPageSet
, self
).__init
__(
407 user_agent_type
='mobile',
408 archive_data_file
='data/tough_scheduling_cases.json',
409 bucket
=page_set_module
.INTERNAL_BUCKET
)
411 # Why: Simple scrolling baseline
412 self
.AddUserStory(ToughSchedulingCasesPage(
413 'file://tough_scheduling_cases/simple_text_page.html',
415 self
.AddUserStory(Page1(self
))
416 self
.AddUserStory(Page2(self
))
417 self
.AddUserStory(Page3(self
))
418 self
.AddUserStory(Page4(self
))
419 # Disabled until crbug.com/413829 is fixed.
420 # self.AddUserStory(Page5(self))
421 # Disabled because of crbug.com/413829 and flakiness crbug.com/368532
422 # self.AddUserStory(Page6(self))
423 # Why: Touch handler scrolling baseline
424 self
.AddUserStory(ToughSchedulingCasesPage(
425 'file://tough_scheduling_cases/touch_handler_scrolling.html',
427 self
.AddUserStory(Page7(self
))
428 self
.AddUserStory(Page8(self
))
429 self
.AddUserStory(Page9(self
))
430 self
.AddUserStory(Page10(self
))
431 self
.AddUserStory(Page11(self
))
432 self
.AddUserStory(Page12(self
))
433 # Why: requestAnimationFrame scrolling baseline
434 self
.AddUserStory(ToughSchedulingCasesPage(
435 'file://tough_scheduling_cases/raf.html',
437 # Why: Test canvas blocking behavior
438 self
.AddUserStory(ToughSchedulingCasesPage(
439 'file://tough_scheduling_cases/raf_canvas.html',
441 # Disabled until crbug.com/413829 is fixed.
442 # self.AddUserStory(Page13(self))
443 # Disabled because of crbug.com/413829 and flakiness crbug.com/368532
444 # self.AddUserStory(Page14(self))
445 self
.AddUserStory(Page15(self
))
446 self
.AddUserStory(Page16(self
))
447 # Why: Test a requestAnimationFrame handler with concurrent CSS animation
448 self
.AddUserStory(ToughSchedulingCasesPage(
449 'file://tough_scheduling_cases/raf_animation.html',
451 # Why: Stress test for the scheduler
452 self
.AddUserStory(ToughSchedulingCasesPage(
453 'file://tough_scheduling_cases/raf_touch_animation.html',
455 self
.AddUserStory(Page17(self
))
456 self
.AddUserStory(Page18(self
))
457 self
.AddUserStory(Page19(self
))
458 self
.AddUserStory(Page20(self
))
459 # Why: Baseline for scrolling in the presence of a no-op touch handler
460 self
.AddUserStory(EmptyTouchHandlerPage(
466 # Why: Slow handler blocks scroll start
467 self
.AddUserStory(EmptyTouchHandlerPage(
473 # Why: Slow handler blocks scroll start until touch ACK timeout
474 self
.AddUserStory(EmptyTouchHandlerPage(
475 name
='desktop_slow_handler',
480 # Why: Scroll bounce showing repeated transitions between scrolling and
481 # sending synchronous touchmove events. Should be nearly as fast as
483 self
.AddUserStory(EmptyTouchHandlerPage(
489 # Why: Scroll bounce with slow handler, repeated blocking.
490 self
.AddUserStory(EmptyTouchHandlerPage(
491 name
='bounce_slow_handler',
496 # Why: Scroll bounce with slow handler on desktop, blocks only once until
498 self
.AddUserStory(EmptyTouchHandlerPage(
499 name
='bounce_desktop_slow_handler',
504 # Why: For measuring the latency of scroll-synchronized effects.
505 self
.AddUserStory(SynchronizedScrollOffsetPage(page_set
=self
))
506 # Why: Test loading a large amount of Javascript.
507 self
.AddUserStory(SecondBatchJsPage(page_set
=self
, variant
='light'))
508 self
.AddUserStory(SecondBatchJsPage(page_set
=self
, variant
='medium'))
509 self
.AddUserStory(SecondBatchJsPage(page_set
=self
, variant
='heavy'))