# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from metrics import gpu_timeline
import page_sets
from telemetry import benchmark
from telemetry.core.platform import tracing_category_filter
from telemetry.web_perf import timeline_based_measurement

TOPLEVEL_GL_CATEGORY = 'gpu_toplevel'
TOPLEVEL_CATEGORIES = ['disabled-by-default-gpu.device',
                       'disabled-by-default-gpu.service']


def _GetGPUTimelineMetric(_):
      return [gpu_timeline.GPUTimelineMetric()]


class _GPUTimes(benchmark.Benchmark):
  def CreateTimelineBasedMeasurementOptions(self):
    cat_string = ','.join(TOPLEVEL_CATEGORIES)
    cat_filter = tracing_category_filter.TracingCategoryFilter(cat_string)

    return timeline_based_measurement.Options(
        overhead_level=cat_filter,
        get_metrics_from_flags_callback=_GetGPUTimelineMetric)


@benchmark.Enabled('android')
class GPUTimesKeyMobileSites(_GPUTimes):
  """Measures GPU timeline metric on key mobile sites."""
  page_set = page_sets.KeyMobileSitesSmoothPageSet


class GPUTimesTop25Sites(_GPUTimes):
  """Measures GPU timeline metric for the top 25 sites."""
  page_set = page_sets.Top25SmoothPageSet

@@ -155,16 +155,50 @@
 E file.%0A
+from benchmarks import silk_flags%0A
 from met
@@ -1169,143 +1169,1108 @@
 et%0A%0A
-%0Aclass GPUTimesTop25Sites(_GPUTimes):%0A  %22%22%22Measures GPU timeline metric for the top 25 sites.%22%22%22%0A  page_set = page_sets.Top25SmoothPageSet
+  @classmethod%0A  def Name(cls):%0A    return 'gpu_times.key_mobile_sites_smooth'%0A%0A@benchmark.Enabled('android')%0Aclass GPUTimesGpuRasterizationKeyMobileSites(_GPUTimes):%0A  %22%22%22Measures GPU timeline metric on key mobile sites with GPU rasterization.%0A  %22%22%22%0A  page_set = page_sets.KeyMobileSitesSmoothPageSet%0A  def CustomizeBrowserOptions(self, options):%0A    silk_flags.CustomizeBrowserOptionsForGpuRasterization(options)%0A%0A  @classmethod%0A  def Name(cls):%0A    return 'gpu_times.gpu_rasterization.key_mobile_sites_smooth'%0A%0Aclass GPUTimesTop25Sites(_GPUTimes):%0A  %22%22%22Measures GPU timeline metric for the top 25 sites.%22%22%22%0A  page_set = page_sets.Top25SmoothPageSet%0A%0A  @classmethod%0A  def Name(cls):%0A    return 'gpu_times.top_25_smooth'%0A%0Aclass GPUTimesGpuRasterizationTop25Sites(_GPUTimes):%0A  %22%22%22Measures GPU timeline metric for the top 25 sites with GPU rasterization.%0A  %22%22%22%0A  page_set = page_sets.Top25SmoothPageSet%0A  def CustomizeBrowserOptions(self, options):%0A    silk_flags.CustomizeBrowserOptionsForGpuRasterization(options)%0A%0A  @classmethod%0A  def Name(cls):%0A    return 'gpu_times.gpu_rasterization.top_25_smooth'
 %0A

Standardize "gpu_times" metric names and add GPU rasterization versions.