Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / tools / perf / page_sets / tough_scheduling_cases.py
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 # pylint: disable=W0401,W0614
5 from telemetry.page.actions.all_page_actions import *
6 from telemetry.page import page as page_module
7 from telemetry.page import page_set as page_set_module
8
9
10 class ToughSchedulingCasesPage(page_module.Page):
11
12   def __init__(self, url, page_set):
13     super(ToughSchedulingCasesPage, self).__init__(url=url, page_set=page_set)
14
15   def RunSmoothness(self, action_runner):
16     action_runner.RunAction(ScrollAction())
17
18
19 class Page1(ToughSchedulingCasesPage):
20
21   """ Why: Simulate oversubscribed main thread """
22
23   def __init__(self, page_set):
24     super(Page1, self).__init__(
25       url='file://tough_scheduling_cases/simple_text_page.html?main_busy',
26       page_set=page_set)
27
28     self.synthetic_delays = {'cc.BeginMainFrame': {'target_duration': 0.008}}
29
30
31 class Page2(ToughSchedulingCasesPage):
32
33   """ Why: Simulate oversubscribed main thread """
34
35   def __init__(self, page_set):
36     super(Page2, self).__init__(
37       # pylint: disable=C0301
38       url='file://tough_scheduling_cases/simple_text_page.html?main_very_busy',
39       page_set=page_set)
40
41     self.synthetic_delays = {'cc.BeginMainFrame': {'target_duration': 0.024}}
42
43
44 class Page3(ToughSchedulingCasesPage):
45
46   """ Why: Simulate a page with a a few graphics layers """
47
48   def __init__(self, page_set):
49     super(Page3, self).__init__(
50       # pylint: disable=C0301
51       url='file://tough_scheduling_cases/simple_text_page.html?medium_layers',
52       page_set=page_set)
53
54     self.synthetic_delays = {
55       'cc.DrawAndSwap': {'target_duration': 0.004},
56       'gpu.PresentingFrame': {'target_duration': 0.004},
57       'cc.BeginMainFrame': {'target_duration': 0.004}
58     }
59
60
61 class Page4(ToughSchedulingCasesPage):
62
63   """ Why: Simulate a page with many graphics layers """
64
65   def __init__(self, page_set):
66     super(Page4, self).__init__(
67       # pylint: disable=C0301
68       url='file://tough_scheduling_cases/simple_text_page.html?many_layers',
69       page_set=page_set)
70
71     self.synthetic_delays = {
72       'cc.DrawAndSwap': {'target_duration': 0.012},
73       'gpu.PresentingFrame': {'target_duration': 0.012},
74       'cc.BeginMainFrame': {'target_duration': 0.012}
75     }
76
77
78 class Page5(ToughSchedulingCasesPage):
79
80   """ Why: Simulate a page with expensive recording and rasterization """
81
82   def __init__(self, page_set):
83     super(Page5, self).__init__(
84       # pylint: disable=C0301
85       url='file://tough_scheduling_cases/simple_text_page.html?medium_raster',
86       page_set=page_set)
87
88     self.synthetic_delays = {
89       'cc.RasterRequiredForActivation': {'target_duration': 0.004},
90       'cc.BeginMainFrame': {'target_duration': 0.004},
91       'gpu.AsyncTexImage': {'target_duration': 0.004}
92     }
93
94
95 class Page6(ToughSchedulingCasesPage):
96
97   """ Why: Simulate a page with expensive recording and rasterization """
98
99   def __init__(self, page_set):
100     super(Page6, self).__init__(
101       # pylint: disable=C0301
102       url='file://tough_scheduling_cases/simple_text_page.html?heavy_raster',
103       page_set=page_set)
104
105     self.synthetic_delays = {
106       'cc.RasterRequiredForActivation': {'target_duration': 0.024},
107       'cc.BeginMainFrame': {'target_duration': 0.024},
108       'gpu.AsyncTexImage': {'target_duration': 0.024}
109     }
110
111
112 class Page7(ToughSchedulingCasesPage):
113
114   """ Why: Medium cost touch handler """
115
116   def __init__(self, page_set):
117     super(Page7, self).__init__(
118       # pylint: disable=C0301
119       url='file://tough_scheduling_cases/touch_handler_scrolling.html?medium_handler',
120       page_set=page_set)
121
122     self.synthetic_delays = {'blink.HandleInputEvent':
123                              {'target_duration': 0.008}}
124
125
126 class Page8(ToughSchedulingCasesPage):
127
128   """ Why: Slow touch handler """
129
130   def __init__(self, page_set):
131     super(Page8, self).__init__(
132       # pylint: disable=C0301
133       url='file://tough_scheduling_cases/touch_handler_scrolling.html?slow_handler',
134       page_set=page_set)
135
136     self.synthetic_delays = {'blink.HandleInputEvent':
137                              {'target_duration': 0.024}}
138
139
140 class Page9(ToughSchedulingCasesPage):
141
142   """ Why: Touch handler that often takes a long time """
143
144   def __init__(self, page_set):
145     super(Page9, self).__init__(
146       # pylint: disable=C0301
147       url='file://tough_scheduling_cases/touch_handler_scrolling.html?janky_handler',
148       page_set=page_set)
149
150     self.synthetic_delays = {'blink.HandleInputEvent':
151                              {'target_duration': 0.024, 'mode': 'alternating'}
152                             }
153
154
155 class Page10(ToughSchedulingCasesPage):
156
157   """ Why: Touch handler that occasionally takes a long time """
158
159   def __init__(self, page_set):
160     super(Page10, self).__init__(
161       # pylint: disable=C0301
162       url='file://tough_scheduling_cases/touch_handler_scrolling.html?occasionally_janky_handler',
163       page_set=page_set)
164
165     self.synthetic_delays = {'blink.HandleInputEvent':
166                              {'target_duration': 0.024, 'mode': 'oneshot'}}
167
168
169 class Page11(ToughSchedulingCasesPage):
170
171   """ Why: Super expensive touch handler causes browser to scroll after a
172   timeout.
173   """
174
175   def __init__(self, page_set):
176     super(Page11, self).__init__(
177       # pylint: disable=C0301
178       url='file://tough_scheduling_cases/touch_handler_scrolling.html?super_slow_handler',
179       page_set=page_set)
180
181     self.synthetic_delays = {'blink.HandleInputEvent':
182                              {'target_duration': 0.2}}
183
184
185 class Page12(ToughSchedulingCasesPage):
186
187   """ Why: Super expensive touch handler that only occupies a part of the page.
188   """
189
190   def __init__(self, page_set):
191     super(Page12, self).__init__(
192       url='file://tough_scheduling_cases/div_touch_handler.html',
193       page_set=page_set)
194
195     self.synthetic_delays = {'blink.HandleInputEvent': {'target_duration': 0.2}}
196
197
198 class Page13(ToughSchedulingCasesPage):
199
200   """ Why: Test a moderately heavy requestAnimationFrame handler """
201
202   def __init__(self, page_set):
203     super(Page13, self).__init__(
204       url='file://tough_scheduling_cases/raf.html?medium_handler',
205       page_set=page_set)
206
207     self.synthetic_delays = {
208       'cc.RasterRequiredForActivation': {'target_duration': 0.004},
209       'cc.BeginMainFrame': {'target_duration': 0.004},
210       'gpu.AsyncTexImage': {'target_duration': 0.004}
211     }
212
213
214 class Page14(ToughSchedulingCasesPage):
215
216   """ Why: Test a moderately heavy requestAnimationFrame handler """
217
218   def __init__(self, page_set):
219     super(Page14, self).__init__(
220       url='file://tough_scheduling_cases/raf.html?heavy_handler',
221       page_set=page_set)
222
223     self.synthetic_delays = {
224       'cc.RasterRequiredForActivation': {'target_duration': 0.024},
225       'cc.BeginMainFrame': {'target_duration': 0.024},
226       'gpu.AsyncTexImage': {'target_duration': 0.024}
227     }
228
229
230 class Page15(ToughSchedulingCasesPage):
231
232   """ Why: Simulate a heavily GPU bound page """
233
234   def __init__(self, page_set):
235     super(Page15, self).__init__(
236       url='file://tough_scheduling_cases/raf.html?gpu_bound',
237       page_set=page_set)
238
239     self.synthetic_delays = {'gpu.PresentingFrame': {'target_duration': 0.1}}
240
241
242 class Page16(ToughSchedulingCasesPage):
243
244   """ Why: Test a requestAnimationFrame handler with a heavy first frame """
245
246   def __init__(self, page_set):
247     super(Page16, self).__init__(
248       url='file://tough_scheduling_cases/raf.html?heavy_first_frame',
249       page_set=page_set)
250
251     self.synthetic_delays = {'cc.BeginMainFrame': {'target_duration': 0.15}}
252
253
254 class Page17(ToughSchedulingCasesPage):
255
256   """ Why: Medium stress test for the scheduler """
257
258   def __init__(self, page_set):
259     super(Page17, self).__init__(
260       url='file://tough_scheduling_cases/raf_touch_animation.html?medium',
261       page_set=page_set)
262
263     self.synthetic_delays = {
264       'cc.DrawAndSwap': {'target_duration': 0.004},
265       'cc.BeginMainFrame': {'target_duration': 0.004}
266     }
267
268
269 class Page18(ToughSchedulingCasesPage):
270
271   """ Why: Heavy stress test for the scheduler """
272
273   def __init__(self, page_set):
274     super(Page18, self).__init__(
275       url='file://tough_scheduling_cases/raf_touch_animation.html?heavy',
276       page_set=page_set)
277
278     self.synthetic_delays = {
279       'cc.DrawAndSwap': {'target_duration': 0.012},
280       'cc.BeginMainFrame': {'target_duration': 0.012}
281     }
282
283
284 class Page19(ToughSchedulingCasesPage):
285
286   """ Why: Both main and impl thread animating concurrently """
287
288   def __init__(self, page_set):
289     super(Page19, self).__init__(
290       url='file://tough_scheduling_cases/split_animation.html',
291       page_set=page_set)
292
293   def RunSmoothness(self, action_runner):
294     action_runner.RunAction(WaitAction(
295       {
296         "seconds": 3
297       }))
298
299 class Page20(ToughSchedulingCasesPage):
300
301   """ Why: Simple JS touch dragging """
302
303   def __init__(self, page_set):
304     super(Page20, self).__init__(
305       url='file://tough_scheduling_cases/simple_touch_drag.html',
306       page_set=page_set)
307
308   def RunSmoothness(self, action_runner):
309     action_runner.RunAction(ScrollAction(
310       {
311         'scrollable_element_function': '''
312           function(callback) {
313             callback(document.getElementById('card'));
314           }''',
315         'scroll_requires_touch': True,
316         'direction': 'up',
317         'speed': 150,
318         'scroll_distance_function': 'function() { return 400; }'
319       }))
320
321 class EmptyTouchHandlerPage(ToughSchedulingCasesPage):
322
323   """ Why: Scrolling on a page with a touch handler that consumes no events but
324       may be slow """
325
326   def __init__(self, name, desktop, slow_handler, bounce, page_set):
327     super(EmptyTouchHandlerPage, self).__init__(
328       url='file://tough_scheduling_cases/empty_touch_handler' +
329         ('_desktop' if desktop else '') + '.html?' + name,
330       page_set=page_set)
331
332     if slow_handler:
333       self.synthetic_delays = {
334         'blink.HandleInputEvent': {'target_duration': 0.2}
335       }
336
337     self.bounce = bounce
338
339   def RunSmoothness(self, action_runner):
340     if self.bounce:
341       action = ScrollBounceAction()
342     else:
343       action = ScrollAction(
344         {
345           'scroll_requires_touch': True,
346            """ Speed and distance are tuned to run exactly as long as a scroll
347                 bounce """
348           'speed': 400,
349           'scroll_distance_function': 'function() { return 2100; }'
350         })
351
352     action_runner.RunAction(action)
353
354 class ToughSchedulingCasesPageSet(page_set_module.PageSet):
355
356   """ Tough scheduler latency test cases """
357
358   def __init__(self):
359     super(ToughSchedulingCasesPageSet, self).__init__()
360
361     # Why: Simple scrolling baseline
362     self.AddPage(ToughSchedulingCasesPage(
363       'file://tough_scheduling_cases/simple_text_page.html',
364       self))
365     self.AddPage(Page1(self))
366     self.AddPage(Page2(self))
367     self.AddPage(Page3(self))
368     self.AddPage(Page4(self))
369     self.AddPage(Page5(self))
370     self.AddPage(Page6(self))
371     # Why: Touch handler scrolling baseline
372     self.AddPage(ToughSchedulingCasesPage(
373       'file://tough_scheduling_cases/touch_handler_scrolling.html',
374       self))
375     self.AddPage(Page7(self))
376     self.AddPage(Page8(self))
377     self.AddPage(Page9(self))
378     self.AddPage(Page10(self))
379     self.AddPage(Page11(self))
380     self.AddPage(Page12(self))
381     # Why: requestAnimationFrame scrolling baseline
382     self.AddPage(ToughSchedulingCasesPage(
383       'file://tough_scheduling_cases/raf.html',
384       self))
385     # Why: Test canvas blocking behavior
386     self.AddPage(ToughSchedulingCasesPage(
387       'file://tough_scheduling_cases/raf_canvas.html',
388       self))
389     self.AddPage(Page13(self))
390     # Disabled for flakiness. See 368532
391     # self.AddPage(Page14(self))
392     self.AddPage(Page15(self))
393     self.AddPage(Page16(self))
394     # Why: Test a requestAnimationFrame handler with concurrent CSS animation
395     self.AddPage(ToughSchedulingCasesPage(
396       'file://tough_scheduling_cases/raf_animation.html',
397       self))
398     # Why: Stress test for the scheduler
399     self.AddPage(ToughSchedulingCasesPage(
400       'file://tough_scheduling_cases/raf_touch_animation.html',
401       self))
402     self.AddPage(Page17(self))
403     self.AddPage(Page18(self))
404     self.AddPage(Page19(self))
405     self.AddPage(Page20(self))
406     # Why: Baseline for scrolling in the presence of a no-op touch handler
407     self.AddPage(EmptyTouchHandlerPage(
408       name='baseline',
409       desktop=False,
410       slow_handler=False,
411       bounce=False,
412       page_set=self))
413     # Why: Slow handler blocks scroll start
414     self.AddPage(EmptyTouchHandlerPage(
415       name='slow_handler',
416       desktop=False,
417       slow_handler=True,
418       bounce=False,
419       page_set=self))
420     # Why: Slow handler blocks scroll start until touch ACK timeout
421     self.AddPage(EmptyTouchHandlerPage(
422       name='desktop_slow_handler',
423       desktop=True,
424       slow_handler=True,
425       bounce=False,
426       page_set=self))
427     # Why: Scroll bounce showing repeated transitions between scrolling and
428     # sending synchronous touchmove events.  Should be nearly as fast as
429     # scroll baseline.
430     self.AddPage(EmptyTouchHandlerPage(
431       name='bounce',
432       desktop=False,
433       slow_handler=False,
434       bounce=True,
435       page_set=self))
436     # Why: Scroll bounce with slow handler, repeated blocking.
437     self.AddPage(EmptyTouchHandlerPage(
438       name='bounce_slow_handler',
439       desktop=False,
440       slow_handler=True,
441       bounce=True,
442       page_set=self))
443     # Why: Scroll bounce with slow handler on desktop, blocks only once until
444     # ACK timeout.
445     self.AddPage(EmptyTouchHandlerPage(
446       name='bounce_desktop_slow_handler',
447       desktop=True,
448       slow_handler=True,
449       bounce=True,
450       page_set=self))
451