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
5from contrib.cluster_telemetry import ct_benchmarks_util
6from contrib.cluster_telemetry import page_set
7from contrib.cluster_telemetry import repaint_helpers
8from telemetry.timeline import chrome_trace_category_filter
9from telemetry.web_perf import timeline_based_measurement
10
11from core import perf_benchmark
12
13
14class RepaintCT(perf_benchmark.PerfBenchmark):
15  """Measures repaint performance for Cluster Telemetry."""
16
17  @classmethod
18  def Name(cls):
19    return 'repaint_ct'
20
21  @classmethod
22  def AddBenchmarkCommandLineArgs(cls, parser):
23    parser.add_option('--mode', type='string',
24                      default='viewport',
25                      help='Invalidation mode. '
26                      'Supported values: fixed_size, layer, random, viewport.')
27    parser.add_option('--width', type='int',
28                      default=None,
29                      help='Width of invalidations for fixed_size mode.')
30    parser.add_option('--height', type='int',
31                      default=None,
32                      help='Height of invalidations for fixed_size mode.')
33    ct_benchmarks_util.AddBenchmarkCommandLineArgs(parser)
34
35  @classmethod
36  def ProcessCommandLineArgs(cls, parser, args):
37    ct_benchmarks_util.ValidateCommandLineArgs(parser, args)
38
39  def CreateStorySet(self, options):
40    return page_set.CTPageSet(
41        options.urls_list, options.user_agent, options.archive_data_file,
42        run_page_interaction_callback=repaint_helpers.WaitThenRepaint)
43
44  def CreateCoreTimelineBasedMeasurementOptions(self):
45    category_filter = chrome_trace_category_filter.CreateLowOverheadFilter()
46    options = timeline_based_measurement.Options(category_filter)
47    options.config.chrome_trace_config.EnableUMAHistograms(
48        'Event.Latency.ScrollBegin.Touch.TimeToScrollUpdateSwapBegin4',
49        'Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin4')
50    options.SetTimelineBasedMetrics(['renderingMetric', 'umaMetric'])
51    return options
52