1# Copyright 2017 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 telemetry.timeline import chrome_trace_category_filter 8from telemetry.web_perf import timeline_based_measurement 9 10from core import perf_benchmark 11 12import benchmarks.rendering as rendering 13 14def ScrollToEndOfPage(action_runner): 15 action_runner.Wait(1) 16 with action_runner.CreateGestureInteraction('ScrollAction'): 17 action_runner.ScrollPage() 18 19 20class RenderingCT(perf_benchmark.PerfBenchmark): 21 """Measures rendering performance for Cluster Telemetry.""" 22 23 options = {'upload_results': True} 24 25 @classmethod 26 def Name(cls): 27 return 'rendering.cluster_telemetry' 28 29 @classmethod 30 def AddBenchmarkCommandLineArgs(cls, parser): 31 ct_benchmarks_util.AddBenchmarkCommandLineArgs(parser) 32 33 @classmethod 34 def ProcessCommandLineArgs(cls, parser, args): 35 ct_benchmarks_util.ValidateCommandLineArgs(parser, args) 36 37 def CreateStorySet(self, options): 38 return page_set.CTPageSet( 39 options.urls_list, options.user_agent, options.archive_data_file, 40 run_page_interaction_callback=ScrollToEndOfPage) 41 42 def CreateCoreTimelineBasedMeasurementOptions(self): 43 category_filter = chrome_trace_category_filter.CreateLowOverheadFilter() 44 options = timeline_based_measurement.Options(category_filter) 45 options.config.chrome_trace_config.EnableUMAHistograms( 46 *rendering.RENDERING_BENCHMARK_UMA) 47 options.SetTimelineBasedMetrics(['renderingMetric', 'umaMetric']) 48 return options 49