[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / tools / perf / page_sets / tough_scheduling_cases.py
blobb30b8ee344b1accfc16ff1b3f3206d07499f7cf5
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(
18 'ScrollAction')
19 action_runner.ScrollPage()
20 interaction.End()
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',
30 page_set=page_set)
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',
43 page_set=page_set)
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',
56 page_set=page_set)
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',
73 page_set=page_set)
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',
90 page_set=page_set)
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',
107 page_set=page_set)
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',
124 page_set=page_set)
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',
138 page_set=page_set)
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',
152 page_set=page_set)
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',
167 page_set=page_set)
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
176 timeout."""
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',
182 page_set=page_set)
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',
196 page_set=page_set)
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',
208 page_set=page_set)
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',
224 page_set=page_set)
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',
240 page_set=page_set)
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',
252 page_set=page_set)
254 self.synthetic_delays = {'cc.BeginMainFrame': {'target_duration': 0.15,
255 'mode': 'oneshot'}}
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',
265 page_set=page_set)
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',
280 page_set=page_set)
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',
295 page_set=page_set)
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',
308 page_set=page_set)
310 def RunPageInteractions(self, action_runner):
311 interaction = action_runner.BeginGestureInteraction(
312 'ScrollAction')
313 action_runner.ScrollElement(
314 selector='#card',
315 use_touch=True,
316 direction='up',
317 speed_in_pixels_per_second=150,
318 distance=400)
319 interaction.End()
322 class EmptyTouchHandlerPage(ToughSchedulingCasesPage):
324 """Why: Scrolling on a page with a touch handler that consumes no events but
325 may be slow."""
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,
331 page_set=page_set)
333 if slow_handler:
334 self.synthetic_delays = {
335 'blink.HandleInputEvent': {'target_duration': 0.2}
338 self.bounce = bounce
340 def RunPageInteractions(self, action_runner):
341 if self.bounce:
342 interaction = action_runner.BeginGestureInteraction(
343 'ScrollBounceAction')
344 action_runner.ScrollBouncePage()
345 interaction.End()
346 else:
347 interaction = action_runner.BeginGestureInteraction(
348 'ScrollAction')
349 # Speed and distance are tuned to run exactly as long as a scroll
350 # bounce.
351 action_runner.ScrollPage(use_touch=True, speed_in_pixels_per_second=400,
352 distance=2100)
353 interaction.End()
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',
363 page_set=page_set)
365 def RunPageInteractions(self, action_runner):
366 interaction = action_runner.BeginGestureInteraction(
367 'ScrollBounceAction')
368 action_runner.ScrollBouncePage()
369 interaction.End()
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,
381 page_set=page_set)
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')
398 interaction.End()
401 class ToughSchedulingCasesPageSet(page_set_module.PageSet):
403 """Tough scheduler latency test cases."""
405 def __init__(self):
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',
414 self))
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',
426 self))
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',
436 self))
437 # Why: Test canvas blocking behavior
438 self.AddUserStory(ToughSchedulingCasesPage(
439 'file://tough_scheduling_cases/raf_canvas.html',
440 self))
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',
450 self))
451 # Why: Stress test for the scheduler
452 self.AddUserStory(ToughSchedulingCasesPage(
453 'file://tough_scheduling_cases/raf_touch_animation.html',
454 self))
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(
461 name='baseline',
462 desktop=False,
463 slow_handler=False,
464 bounce=False,
465 page_set=self))
466 # Why: Slow handler blocks scroll start
467 self.AddUserStory(EmptyTouchHandlerPage(
468 name='slow_handler',
469 desktop=False,
470 slow_handler=True,
471 bounce=False,
472 page_set=self))
473 # Why: Slow handler blocks scroll start until touch ACK timeout
474 self.AddUserStory(EmptyTouchHandlerPage(
475 name='desktop_slow_handler',
476 desktop=True,
477 slow_handler=True,
478 bounce=False,
479 page_set=self))
480 # Why: Scroll bounce showing repeated transitions between scrolling and
481 # sending synchronous touchmove events. Should be nearly as fast as
482 # scroll baseline.
483 self.AddUserStory(EmptyTouchHandlerPage(
484 name='bounce',
485 desktop=False,
486 slow_handler=False,
487 bounce=True,
488 page_set=self))
489 # Why: Scroll bounce with slow handler, repeated blocking.
490 self.AddUserStory(EmptyTouchHandlerPage(
491 name='bounce_slow_handler',
492 desktop=False,
493 slow_handler=True,
494 bounce=True,
495 page_set=self))
496 # Why: Scroll bounce with slow handler on desktop, blocks only once until
497 # ACK timeout.
498 self.AddUserStory(EmptyTouchHandlerPage(
499 name='bounce_desktop_slow_handler',
500 desktop=True,
501 slow_handler=True,
502 bounce=True,
503 page_set=self))
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'))