cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / tools / perf / measurements / smoothness.py
blob41578132545844f2a5ea75d77a30d9cfd9766252
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
8 from telemetry.web_perf.metrics import smoothness
11 class _CustomResultsWrapper(timeline_based_measurement.ResultsWrapperInterface):
12 def __init__(self):
13 super(_CustomResultsWrapper, self).__init__()
14 self._pages_to_tir_labels = {}
16 def _AssertNewValueHasSameInteractionLabel(self, new_value):
17 tir_label = self._pages_to_tir_labels.get(new_value.page)
18 if tir_label:
19 assert tir_label == self._tir_label, (
20 'Smoothness measurement do not support multiple interaction record '
21 'labels per page yet. See crbug.com/453109 for more information.')
22 else:
23 self._pages_to_tir_labels[new_value.page] = self._tir_label
25 def AddValue(self, value):
26 self._AssertNewValueHasSameInteractionLabel(value)
27 self._results.AddValue(value)
30 class Smoothness(page_test.PageTest):
31 def __init__(self, needs_browser_restart_after_each_page=False):
32 super(Smoothness, self).__init__(needs_browser_restart_after_each_page)
33 self._results_wrapper = _CustomResultsWrapper()
34 self._tbm = None
36 @classmethod
37 def CustomizeBrowserOptions(cls, options):
38 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking')
39 options.AppendExtraBrowserArgs('--touch-events=enabled')
40 options.AppendExtraBrowserArgs('--running-performance-benchmark')
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
46 custom_categories = [
47 'webkit.console', 'blink.console', 'benchmark', 'trace_event_overhead']
48 category_filter = tracing_category_filter.TracingCategoryFilter(
49 ','.join(custom_categories))
51 options = timeline_based_measurement.Options(category_filter)
52 options.SetTimelineBasedMetrics([smoothness.SmoothnessMetric()])
53 self._tbm = timeline_based_measurement.TimelineBasedMeasurement(
54 options, self._results_wrapper)
55 self._tbm.WillRunStoryForPageTest(
56 tracing_controller, page.GetSyntheticDelayCategories())
58 def ValidateAndMeasurePage(self, _, tab, results):
59 tracing_controller = tab.browser.platform.tracing_controller
60 self._tbm.MeasureForPageTest(tracing_controller, results)
62 def DidRunPage(self, platform):
63 if self._tbm:
64 self._tbm.DidRunStoryForPageTest(platform.tracing_controller)
67 class Repaint(Smoothness):
68 def CustomizeBrowserOptions(self, options):
69 options.AppendExtraBrowserArgs([
70 '--enable-impl-side-painting',
71 '--enable-threaded-compositing',
72 '--enable-gpu-benchmarking'
75 class SmoothnessWithRestart(Smoothness):
76 def __init__(self):
77 super(SmoothnessWithRestart, self).__init__(
78 needs_browser_restart_after_each_page=True)