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
__(url
=url
, page_set
=page_set
)
13 def RunSmoothness(self
, action_runner
):
14 interaction
= action_runner
.BeginGestureInteraction(
15 'ScrollAction', is_smooth
=True)
16 action_runner
.ScrollPage()
20 class Page1(ToughSchedulingCasesPage
):
22 """ Why: Simulate oversubscribed main thread """
24 def __init__(self
, page_set
):
25 super(Page1
, self
).__init
__(
26 url
='file://tough_scheduling_cases/simple_text_page.html?main_busy',
29 self
.synthetic_delays
= {'cc.BeginMainFrame': {'target_duration': 0.008}}
32 class Page2(ToughSchedulingCasesPage
):
34 """ Why: Simulate oversubscribed main thread """
36 def __init__(self
, page_set
):
37 super(Page2
, self
).__init
__(
38 # pylint: disable=C0301
39 url
='file://tough_scheduling_cases/simple_text_page.html?main_very_busy',
42 self
.synthetic_delays
= {'cc.BeginMainFrame': {'target_duration': 0.024}}
45 class Page3(ToughSchedulingCasesPage
):
47 """ Why: Simulate a page with a a few graphics layers """
49 def __init__(self
, page_set
):
50 super(Page3
, self
).__init
__(
51 # pylint: disable=C0301
52 url
='file://tough_scheduling_cases/simple_text_page.html?medium_layers',
55 self
.synthetic_delays
= {
56 'cc.DrawAndSwap': {'target_duration': 0.004},
57 'gpu.PresentingFrame': {'target_duration': 0.004},
58 'cc.BeginMainFrame': {'target_duration': 0.004}
62 class Page4(ToughSchedulingCasesPage
):
64 """ Why: Simulate a page with many graphics layers """
66 def __init__(self
, page_set
):
67 super(Page4
, self
).__init
__(
68 # pylint: disable=C0301
69 url
='file://tough_scheduling_cases/simple_text_page.html?many_layers',
72 self
.synthetic_delays
= {
73 'cc.DrawAndSwap': {'target_duration': 0.012},
74 'gpu.PresentingFrame': {'target_duration': 0.012},
75 'cc.BeginMainFrame': {'target_duration': 0.012}
79 class Page5(ToughSchedulingCasesPage
):
81 """ Why: Simulate a page with expensive recording and rasterization """
83 def __init__(self
, page_set
):
84 super(Page5
, self
).__init
__(
85 # pylint: disable=C0301
86 url
='file://tough_scheduling_cases/simple_text_page.html?medium_raster',
89 self
.synthetic_delays
= {
90 'cc.RasterRequiredForActivation': {'target_duration': 0.004},
91 'cc.BeginMainFrame': {'target_duration': 0.004},
92 'gpu.AsyncTexImage': {'target_duration': 0.004}
96 class Page6(ToughSchedulingCasesPage
):
98 """ Why: Simulate a page with expensive recording and rasterization """
100 def __init__(self
, page_set
):
101 super(Page6
, self
).__init
__(
102 # pylint: disable=C0301
103 url
='file://tough_scheduling_cases/simple_text_page.html?heavy_raster',
106 self
.synthetic_delays
= {
107 'cc.RasterRequiredForActivation': {'target_duration': 0.024},
108 'cc.BeginMainFrame': {'target_duration': 0.024},
109 'gpu.AsyncTexImage': {'target_duration': 0.024}
113 class Page7(ToughSchedulingCasesPage
):
115 """ Why: Medium cost touch handler """
117 def __init__(self
, page_set
):
118 super(Page7
, self
).__init
__(
119 # pylint: disable=C0301
120 url
='file://tough_scheduling_cases/touch_handler_scrolling.html?medium_handler',
123 self
.synthetic_delays
= {'blink.HandleInputEvent':
124 {'target_duration': 0.008}}
127 class Page8(ToughSchedulingCasesPage
):
129 """ Why: Slow touch handler """
131 def __init__(self
, page_set
):
132 super(Page8
, self
).__init
__(
133 # pylint: disable=C0301
134 url
='file://tough_scheduling_cases/touch_handler_scrolling.html?slow_handler',
137 self
.synthetic_delays
= {'blink.HandleInputEvent':
138 {'target_duration': 0.024}}
141 class Page9(ToughSchedulingCasesPage
):
143 """ Why: Touch handler that often takes a long time """
145 def __init__(self
, page_set
):
146 super(Page9
, self
).__init
__(
147 # pylint: disable=C0301
148 url
='file://tough_scheduling_cases/touch_handler_scrolling.html?janky_handler',
151 self
.synthetic_delays
= {'blink.HandleInputEvent':
152 {'target_duration': 0.024, 'mode': 'alternating'}
156 class Page10(ToughSchedulingCasesPage
):
158 """ Why: Touch handler that occasionally takes a long time """
160 def __init__(self
, page_set
):
161 super(Page10
, self
).__init
__(
162 # pylint: disable=C0301
163 url
='file://tough_scheduling_cases/touch_handler_scrolling.html?occasionally_janky_handler',
166 self
.synthetic_delays
= {'blink.HandleInputEvent':
167 {'target_duration': 0.024, 'mode': 'oneshot'}}
170 class Page11(ToughSchedulingCasesPage
):
172 """ Why: Super expensive touch handler causes browser to scroll after a
176 def __init__(self
, page_set
):
177 super(Page11
, self
).__init
__(
178 # pylint: disable=C0301
179 url
='file://tough_scheduling_cases/touch_handler_scrolling.html?super_slow_handler',
182 self
.synthetic_delays
= {'blink.HandleInputEvent':
183 {'target_duration': 0.2}}
186 class Page12(ToughSchedulingCasesPage
):
188 """ Why: Super expensive touch handler that only occupies a part of the page.
191 def __init__(self
, page_set
):
192 super(Page12
, self
).__init
__(
193 url
='file://tough_scheduling_cases/div_touch_handler.html',
196 self
.synthetic_delays
= {'blink.HandleInputEvent': {'target_duration': 0.2}}
199 class Page13(ToughSchedulingCasesPage
):
201 """ Why: Test a moderately heavy requestAnimationFrame handler """
203 def __init__(self
, page_set
):
204 super(Page13
, self
).__init
__(
205 url
='file://tough_scheduling_cases/raf.html?medium_handler',
208 self
.synthetic_delays
= {
209 'cc.RasterRequiredForActivation': {'target_duration': 0.004},
210 'cc.BeginMainFrame': {'target_duration': 0.004},
211 'gpu.AsyncTexImage': {'target_duration': 0.004}
215 class Page14(ToughSchedulingCasesPage
):
217 """ Why: Test a moderately heavy requestAnimationFrame handler """
219 def __init__(self
, page_set
):
220 super(Page14
, self
).__init
__(
221 url
='file://tough_scheduling_cases/raf.html?heavy_handler',
224 self
.synthetic_delays
= {
225 'cc.RasterRequiredForActivation': {'target_duration': 0.024},
226 'cc.BeginMainFrame': {'target_duration': 0.024},
227 'gpu.AsyncTexImage': {'target_duration': 0.024}
231 class Page15(ToughSchedulingCasesPage
):
233 """ Why: Simulate a heavily GPU bound page """
235 def __init__(self
, page_set
):
236 super(Page15
, self
).__init
__(
237 url
='file://tough_scheduling_cases/raf.html?gpu_bound',
240 self
.synthetic_delays
= {'gpu.PresentingFrame': {'target_duration': 0.1}}
243 class Page16(ToughSchedulingCasesPage
):
245 """ Why: Test a requestAnimationFrame handler with a heavy first frame """
247 def __init__(self
, page_set
):
248 super(Page16
, self
).__init
__(
249 url
='file://tough_scheduling_cases/raf.html?heavy_first_frame',
252 self
.synthetic_delays
= {'cc.BeginMainFrame': {'target_duration': 0.15}}
255 class Page17(ToughSchedulingCasesPage
):
257 """ Why: Medium stress test for the scheduler """
259 def __init__(self
, page_set
):
260 super(Page17
, self
).__init
__(
261 url
='file://tough_scheduling_cases/raf_touch_animation.html?medium',
264 self
.synthetic_delays
= {
265 'cc.DrawAndSwap': {'target_duration': 0.004},
266 'cc.BeginMainFrame': {'target_duration': 0.004}
270 class Page18(ToughSchedulingCasesPage
):
272 """ Why: Heavy stress test for the scheduler """
274 def __init__(self
, page_set
):
275 super(Page18
, self
).__init
__(
276 url
='file://tough_scheduling_cases/raf_touch_animation.html?heavy',
279 self
.synthetic_delays
= {
280 'cc.DrawAndSwap': {'target_duration': 0.012},
281 'cc.BeginMainFrame': {'target_duration': 0.012}
285 class Page19(ToughSchedulingCasesPage
):
287 """ Why: Both main and impl thread animating concurrently """
289 def __init__(self
, page_set
):
290 super(Page19
, self
).__init
__(
291 url
='file://tough_scheduling_cases/split_animation.html',
294 def RunSmoothness(self
, action_runner
):
295 action_runner
.Wait(3)
298 class Page20(ToughSchedulingCasesPage
):
300 """ Why: Simple JS touch dragging """
302 def __init__(self
, page_set
):
303 super(Page20
, self
).__init
__(
304 url
='file://tough_scheduling_cases/simple_touch_drag.html',
307 def RunSmoothness(self
, action_runner
):
308 interaction
= action_runner
.BeginGestureInteraction(
309 'ScrollAction', is_smooth
=True)
310 action_runner
.ScrollElement(
314 speed_in_pixels_per_second
=150,
319 class EmptyTouchHandlerPage(ToughSchedulingCasesPage
):
321 """ Why: Scrolling on a page with a touch handler that consumes no events but
324 def __init__(self
, name
, desktop
, slow_handler
, bounce
, page_set
):
325 super(EmptyTouchHandlerPage
, self
).__init
__(
326 url
='file://tough_scheduling_cases/empty_touch_handler' +
327 ('_desktop' if desktop
else '') + '.html?' + name
,
331 self
.synthetic_delays
= {
332 'blink.HandleInputEvent': {'target_duration': 0.2}
337 def RunSmoothness(self
, action_runner
):
339 interaction
= action_runner
.BeginGestureInteraction(
340 'ScrollBounceAction', is_smooth
=True)
341 action_runner
.ScrollBouncePage()
344 interaction
= action_runner
.BeginGestureInteraction(
345 'ScrollAction', is_smooth
=True)
346 # Speed and distance are tuned to run exactly as long as a scroll
348 action_runner
.ScrollPage(use_touch
=True, speed_in_pixels_per_second
=400,
353 class SynchronizedScrollOffsetPage(ToughSchedulingCasesPage
):
355 """Why: For measuring the latency of scroll-synchronized effects."""
357 def __init__(self
, page_set
):
358 super(SynchronizedScrollOffsetPage
, self
).__init
__(
359 url
='file://tough_scheduling_cases/sync_scroll_offset.html',
362 def RunSmoothness(self
, action_runner
):
363 interaction
= action_runner
.BeginGestureInteraction(
364 'ScrollBounceAction', is_smooth
=True)
365 action_runner
.ScrollBouncePage()
369 class ToughSchedulingCasesPageSet(page_set_module
.PageSet
):
371 """ Tough scheduler latency test cases """
374 super(ToughSchedulingCasesPageSet
, self
).__init
__()
376 # Why: Simple scrolling baseline
377 self
.AddPage(ToughSchedulingCasesPage(
378 'file://tough_scheduling_cases/simple_text_page.html',
380 self
.AddPage(Page1(self
))
381 self
.AddPage(Page2(self
))
382 self
.AddPage(Page3(self
))
383 self
.AddPage(Page4(self
))
384 self
.AddPage(Page5(self
))
385 # self.AddPage(Page6(self)) Flaky crbug.com/368532
386 # Why: Touch handler scrolling baseline
387 self
.AddPage(ToughSchedulingCasesPage(
388 'file://tough_scheduling_cases/touch_handler_scrolling.html',
390 self
.AddPage(Page7(self
))
391 self
.AddPage(Page8(self
))
392 self
.AddPage(Page9(self
))
393 self
.AddPage(Page10(self
))
394 self
.AddPage(Page11(self
))
395 self
.AddPage(Page12(self
))
396 # Why: requestAnimationFrame scrolling baseline
397 self
.AddPage(ToughSchedulingCasesPage(
398 'file://tough_scheduling_cases/raf.html',
400 # Why: Test canvas blocking behavior
401 self
.AddPage(ToughSchedulingCasesPage(
402 'file://tough_scheduling_cases/raf_canvas.html',
404 self
.AddPage(Page13(self
))
405 # Disabled for flakiness. See 368532
406 # self.AddPage(Page14(self))
407 self
.AddPage(Page15(self
))
408 self
.AddPage(Page16(self
))
409 # Why: Test a requestAnimationFrame handler with concurrent CSS animation
410 self
.AddPage(ToughSchedulingCasesPage(
411 'file://tough_scheduling_cases/raf_animation.html',
413 # Why: Stress test for the scheduler
414 self
.AddPage(ToughSchedulingCasesPage(
415 'file://tough_scheduling_cases/raf_touch_animation.html',
417 self
.AddPage(Page17(self
))
418 self
.AddPage(Page18(self
))
419 self
.AddPage(Page19(self
))
420 self
.AddPage(Page20(self
))
421 # Why: Baseline for scrolling in the presence of a no-op touch handler
422 self
.AddPage(EmptyTouchHandlerPage(
428 # Why: Slow handler blocks scroll start
429 self
.AddPage(EmptyTouchHandlerPage(
435 # Why: Slow handler blocks scroll start until touch ACK timeout
436 self
.AddPage(EmptyTouchHandlerPage(
437 name
='desktop_slow_handler',
442 # Why: Scroll bounce showing repeated transitions between scrolling and
443 # sending synchronous touchmove events. Should be nearly as fast as
445 self
.AddPage(EmptyTouchHandlerPage(
451 # Why: Scroll bounce with slow handler, repeated blocking.
452 self
.AddPage(EmptyTouchHandlerPage(
453 name
='bounce_slow_handler',
458 # Why: Scroll bounce with slow handler on desktop, blocks only once until
460 self
.AddPage(EmptyTouchHandlerPage(
461 name
='bounce_desktop_slow_handler',
466 # Why: For measuring the latency of scroll-synchronized effects.
467 self
.AddPage(SynchronizedScrollOffsetPage(page_set
=self
))