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 RunSmoothness(self
, action_runner
):
17 interaction
= action_runner
.BeginGestureInteraction(
18 'ScrollAction', is_smooth
=True)
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
179 def __init__(self
, page_set
):
180 super(Page11
, self
).__init
__(
181 # pylint: disable=C0301
182 url
='file://tough_scheduling_cases/touch_handler_scrolling.html?super_slow_handler',
185 self
.synthetic_delays
= {'blink.HandleInputEvent':
186 {'target_duration': 0.2}}
189 class Page12(ToughSchedulingCasesPage
):
191 """ Why: Super expensive touch handler that only occupies a part of the page.
194 def __init__(self
, page_set
):
195 super(Page12
, self
).__init
__(
196 url
='file://tough_scheduling_cases/div_touch_handler.html',
199 self
.synthetic_delays
= {'blink.HandleInputEvent': {'target_duration': 0.2}}
202 class Page13(ToughSchedulingCasesPage
):
204 """ Why: Test a moderately heavy requestAnimationFrame handler """
206 def __init__(self
, page_set
):
207 super(Page13
, self
).__init
__(
208 url
='file://tough_scheduling_cases/raf.html?medium_handler',
211 self
.synthetic_delays
= {
212 'cc.RasterRequiredForActivation': {'target_duration': 0.004},
213 'cc.BeginMainFrame': {'target_duration': 0.004},
214 'gpu.AsyncTexImage': {'target_duration': 0.004}
218 class Page14(ToughSchedulingCasesPage
):
220 """ Why: Test a moderately heavy requestAnimationFrame handler """
222 def __init__(self
, page_set
):
223 super(Page14
, self
).__init
__(
224 url
='file://tough_scheduling_cases/raf.html?heavy_handler',
227 self
.synthetic_delays
= {
228 'cc.RasterRequiredForActivation': {'target_duration': 0.024},
229 'cc.BeginMainFrame': {'target_duration': 0.024},
230 'gpu.AsyncTexImage': {'target_duration': 0.024}
234 class Page15(ToughSchedulingCasesPage
):
236 """ Why: Simulate a heavily GPU bound page """
238 def __init__(self
, page_set
):
239 super(Page15
, self
).__init
__(
240 url
='file://tough_scheduling_cases/raf.html?gpu_bound',
243 self
.synthetic_delays
= {'gpu.PresentingFrame': {'target_duration': 0.1}}
246 class Page16(ToughSchedulingCasesPage
):
248 """ Why: Test a requestAnimationFrame handler with a heavy first frame """
250 def __init__(self
, page_set
):
251 super(Page16
, self
).__init
__(
252 url
='file://tough_scheduling_cases/raf.html?heavy_first_frame',
255 self
.synthetic_delays
= {'cc.BeginMainFrame': {'target_duration': 0.15,
259 class Page17(ToughSchedulingCasesPage
):
261 """ Why: Medium stress test for the scheduler """
263 def __init__(self
, page_set
):
264 super(Page17
, self
).__init
__(
265 url
='file://tough_scheduling_cases/raf_touch_animation.html?medium',
268 self
.synthetic_delays
= {
269 'cc.DrawAndSwap': {'target_duration': 0.004},
270 'cc.BeginMainFrame': {'target_duration': 0.004}
274 class Page18(ToughSchedulingCasesPage
):
276 """ Why: Heavy stress test for the scheduler """
278 def __init__(self
, page_set
):
279 super(Page18
, self
).__init
__(
280 url
='file://tough_scheduling_cases/raf_touch_animation.html?heavy',
283 self
.synthetic_delays
= {
284 'cc.DrawAndSwap': {'target_duration': 0.012},
285 'cc.BeginMainFrame': {'target_duration': 0.012}
289 class Page19(ToughSchedulingCasesPage
):
291 """ Why: Both main and impl thread animating concurrently """
293 def __init__(self
, page_set
):
294 super(Page19
, self
).__init
__(
295 url
='file://tough_scheduling_cases/split_animation.html',
298 def RunSmoothness(self
, action_runner
):
299 action_runner
.Wait(3)
302 class Page20(ToughSchedulingCasesPage
):
304 """ Why: Simple JS touch dragging """
306 def __init__(self
, page_set
):
307 super(Page20
, self
).__init
__(
308 url
='file://tough_scheduling_cases/simple_touch_drag.html',
311 def RunSmoothness(self
, action_runner
):
312 interaction
= action_runner
.BeginGestureInteraction(
313 'ScrollAction', is_smooth
=True)
314 action_runner
.ScrollElement(
318 speed_in_pixels_per_second
=150,
323 class EmptyTouchHandlerPage(ToughSchedulingCasesPage
):
325 """ Why: Scrolling on a page with a touch handler that consumes no events but
328 def __init__(self
, name
, desktop
, slow_handler
, bounce
, page_set
):
329 super(EmptyTouchHandlerPage
, self
).__init
__(
330 url
='file://tough_scheduling_cases/empty_touch_handler' +
331 ('_desktop' if desktop
else '') + '.html?' + name
,
335 self
.synthetic_delays
= {
336 'blink.HandleInputEvent': {'target_duration': 0.2}
341 def RunSmoothness(self
, action_runner
):
343 interaction
= action_runner
.BeginGestureInteraction(
344 'ScrollBounceAction', is_smooth
=True)
345 action_runner
.ScrollBouncePage()
348 interaction
= action_runner
.BeginGestureInteraction(
349 'ScrollAction', is_smooth
=True)
350 # Speed and distance are tuned to run exactly as long as a scroll
352 action_runner
.ScrollPage(use_touch
=True, speed_in_pixels_per_second
=400,
357 class SynchronizedScrollOffsetPage(ToughSchedulingCasesPage
):
359 """Why: For measuring the latency of scroll-synchronized effects."""
361 def __init__(self
, page_set
):
362 super(SynchronizedScrollOffsetPage
, self
).__init
__(
363 url
='file://tough_scheduling_cases/sync_scroll_offset.html',
366 def RunSmoothness(self
, action_runner
):
367 interaction
= action_runner
.BeginGestureInteraction(
368 'ScrollBounceAction', is_smooth
=True)
369 action_runner
.ScrollBouncePage()
373 class ToughSchedulingCasesPageSet(page_set_module
.PageSet
):
375 """ Tough scheduler latency test cases """
378 super(ToughSchedulingCasesPageSet
, self
).__init
__(
379 user_agent_type
='mobile',
380 archive_data_file
='data/tough_scheduling_cases.json',
381 bucket
=page_set_module
.INTERNAL_BUCKET
)
383 # Why: Simple scrolling baseline
384 self
.AddPage(ToughSchedulingCasesPage(
385 'file://tough_scheduling_cases/simple_text_page.html',
387 self
.AddPage(Page1(self
))
388 self
.AddPage(Page2(self
))
389 self
.AddPage(Page3(self
))
390 self
.AddPage(Page4(self
))
391 # Disabled until crbug.com/413829 is fixed.
392 # self.AddPage(Page5(self))
393 # Disabled because of crbug.com/413829 and flakiness crbug.com/368532
394 # self.AddPage(Page6(self))
395 # Why: Touch handler scrolling baseline
396 self
.AddPage(ToughSchedulingCasesPage(
397 'file://tough_scheduling_cases/touch_handler_scrolling.html',
399 self
.AddPage(Page7(self
))
400 self
.AddPage(Page8(self
))
401 self
.AddPage(Page9(self
))
402 self
.AddPage(Page10(self
))
403 self
.AddPage(Page11(self
))
404 self
.AddPage(Page12(self
))
405 # Why: requestAnimationFrame scrolling baseline
406 self
.AddPage(ToughSchedulingCasesPage(
407 'file://tough_scheduling_cases/raf.html',
409 # Why: Test canvas blocking behavior
410 self
.AddPage(ToughSchedulingCasesPage(
411 'file://tough_scheduling_cases/raf_canvas.html',
413 # Disabled until crbug.com/413829 is fixed.
414 # self.AddPage(Page13(self))
415 # Disabled because of crbug.com/413829 and flakiness crbug.com/368532
416 # self.AddPage(Page14(self))
417 self
.AddPage(Page15(self
))
418 self
.AddPage(Page16(self
))
419 # Why: Test a requestAnimationFrame handler with concurrent CSS animation
420 self
.AddPage(ToughSchedulingCasesPage(
421 'file://tough_scheduling_cases/raf_animation.html',
423 # Why: Stress test for the scheduler
424 self
.AddPage(ToughSchedulingCasesPage(
425 'file://tough_scheduling_cases/raf_touch_animation.html',
427 self
.AddPage(Page17(self
))
428 self
.AddPage(Page18(self
))
429 self
.AddPage(Page19(self
))
430 self
.AddPage(Page20(self
))
431 # Why: Baseline for scrolling in the presence of a no-op touch handler
432 self
.AddPage(EmptyTouchHandlerPage(
438 # Why: Slow handler blocks scroll start
439 self
.AddPage(EmptyTouchHandlerPage(
445 # Why: Slow handler blocks scroll start until touch ACK timeout
446 self
.AddPage(EmptyTouchHandlerPage(
447 name
='desktop_slow_handler',
452 # Why: Scroll bounce showing repeated transitions between scrolling and
453 # sending synchronous touchmove events. Should be nearly as fast as
455 self
.AddPage(EmptyTouchHandlerPage(
461 # Why: Scroll bounce with slow handler, repeated blocking.
462 self
.AddPage(EmptyTouchHandlerPage(
463 name
='bounce_slow_handler',
468 # Why: Scroll bounce with slow handler on desktop, blocks only once until
470 self
.AddPage(EmptyTouchHandlerPage(
471 name
='bounce_desktop_slow_handler',
476 # Why: For measuring the latency of scroll-synchronized effects.
477 self
.AddPage(SynchronizedScrollOffsetPage(page_set
=self
))
478 # Why: Good examples of poor initial scrolling
479 self
.AddPage(ToughSchedulingCasesPage(
480 'http://www.latimes.com',
482 self
.AddPage(ToughSchedulingCasesPage(
483 'http://m.espn.go.com/nhl/rankings',