1 # Copyright 2013 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.
5 from telemetry
.page
import page_test
6 from telemetry
.timeline
import tracing_category_filter
7 from telemetry
.web_perf
import timeline_based_measurement
10 class _CustomResultsWrapper(timeline_based_measurement
.ResultsWrapperInterface
):
12 super(_CustomResultsWrapper
, self
).__init
__()
13 self
._pages
_to
_tir
_labels
= {}
15 def _AssertNewValueHasSameInteractionLabel(self
, new_value
):
16 tir_label
= self
._pages
_to
_tir
_labels
.get(new_value
.page
)
18 assert tir_label
== self
._tir
_label
, (
19 'Smoothness measurement do not support multiple interaction record '
20 'labels per page yet. See crbug.com/453109 for more information.')
22 self
._pages
_to
_tir
_labels
[new_value
.page
] = self
._tir
_label
24 def AddValue(self
, value
):
25 self
._AssertNewValueHasSameInteractionLabel
(value
)
26 self
._results
.AddValue(value
)
29 class Smoothness(page_test
.PageTest
):
30 def __init__(self
, needs_browser_restart_after_each_page
=False):
31 super(Smoothness
, self
).__init
__(needs_browser_restart_after_each_page
)
32 self
._results
_wrapper
= _CustomResultsWrapper()
36 def CustomizeBrowserOptions(cls
, options
):
37 options
.AppendExtraBrowserArgs('--enable-gpu-benchmarking')
38 options
.AppendExtraBrowserArgs('--touch-events=enabled')
39 options
.AppendExtraBrowserArgs('--running-performance-benchmark')
40 options
.AppendExtraBrowserArgs('--js-flags=--expose-gc')
42 def WillNavigateToPage(self
, page
, tab
):
43 tracing_controller
= tab
.browser
.platform
.tracing_controller
44 # FIXME: Remove webkit.console when blink.console lands in chromium and
45 # the ref builds are updated. crbug.com/386847
47 'webkit.console', 'blink.console', 'benchmark', 'trace_event_overhead']
48 category_filter
= tracing_category_filter
.TracingCategoryFilter(
49 ','.join(custom_categories
))
50 self
._tbm
= timeline_based_measurement
.TimelineBasedMeasurement(
51 timeline_based_measurement
.Options(category_filter
),
52 self
._results
_wrapper
)
53 self
._tbm
.WillRunStoryForPageTest(
54 tracing_controller
, page
.GetSyntheticDelayCategories())
56 def ValidateAndMeasurePage(self
, _
, tab
, results
):
57 tracing_controller
= tab
.browser
.platform
.tracing_controller
58 self
._tbm
.MeasureForPageTest(tracing_controller
, results
)
60 def DidRunPage(self
, platform
):
62 self
._tbm
.DidRunStoryForPageTest(platform
.tracing_controller
)
65 class Repaint(Smoothness
):
66 def CustomizeBrowserOptions(self
, options
):
67 options
.AppendExtraBrowserArgs([
68 '--enable-impl-side-painting',
69 '--enable-threaded-compositing',
70 '--enable-gpu-benchmarking'
73 class SmoothnessWithRestart(Smoothness
):
75 super(SmoothnessWithRestart
, self
).__init
__(
76 needs_browser_restart_after_each_page
=True)