Commit 8f61186f authored by Ravi Mistry's avatar Ravi Mistry Committed by Commit Bot

New analysis_metrics_ct benchmark

Also creates new local_trace_measurement and shared_browserless_story for the benchmark to  use.

Depends on https://chromium-review.googlesource.com/c/catapult/+/1017440/ landing first and rolling into chromium.

Bug: skia:7796
Change-Id: I7503f19b90c6231b96547d480c7fb13d1dd79071
Reviewed-on: https://chromium-review.googlesource.com/1019640Reviewed-by: default avatarJuan Antonio Navarro Pérez <perezju@chromium.org>
Reviewed-by: default avatarNed Nguyen <nednguyen@google.com>
Commit-Queue: Ravi Mistry <rmistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553052}
parent b218f3e0
# Copyright 2018 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 core import perf_benchmark
from contrib.cluster_telemetry import ct_benchmarks_util
from contrib.cluster_telemetry import local_trace_measurement
from contrib.cluster_telemetry import page_set
from telemetry.web_perf import timeline_based_measurement
class AnalysisMetricsCT(perf_benchmark.PerfBenchmark):
"""Benchmark that reads in the provided local trace file and invokes TBMv2
metrics on that trace"""
test = local_trace_measurement.LocalTraceMeasurement
metric_name = "" # Set by ProcessCommandLineArgs.
def CreateCoreTimelineBasedMeasurementOptions(self):
tbm_options = timeline_based_measurement.Options()
tbm_options.AddTimelineBasedMetric(AnalysisMetricsCT.metric_name)
return tbm_options
@classmethod
def AddBenchmarkCommandLineArgs(cls, parser):
super(AnalysisMetricsCT, cls).AddBenchmarkCommandLineArgs(parser)
ct_benchmarks_util.AddBenchmarkCommandLineArgs(parser)
parser.add_option('--metric-name', type='string',
default=None,
help='The metric to parse the trace with')
@classmethod
def ProcessCommandLineArgs(cls, parser, args):
if not args.urls_list:
parser.error('Please specify --urls-list')
if not args.metric_name:
parser.error('Please specify --metric-name')
cls.metric_name = args.metric_name
def CreateStorySet(self, options):
return page_set.CTBrowserLessPageSet(options.urls_list)
@classmethod
def Name(cls):
return 'analysis_metrics_ct'
# Copyright 2018 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.
import logging
import os
import time
from telemetry.value import common_value_helpers
from telemetry.web_perf import timeline_based_measurement
from tracing.metrics import metric_runner
class LocalTraceMeasurement(
timeline_based_measurement.TimelineBasedMeasurement):
"""Collects metrics from the provided trace file."""
def __init__(self, options, results_wrapper=None):
super(LocalTraceMeasurement, self).__init__(options, results_wrapper)
def WillRunStory(self, platform):
"""Executes any necessary actions before running the story."""
pass
def Measure(self, platform, results):
"""Collect all possible metrics and add them to results."""
# Extract the file name without the "file:/" prefix.
filename = results.current_page.name[len("file:/"):]
metrics = self._tbm_options.GetTimelineBasedMetrics()
extra_import_options = {
'trackDetailedModelStats': True
}
trace_size_in_mib = os.path.getsize(filename) / (2 ** 20)
# Bails out on trace that are too big. See crbug.com/812631 for more
# details.
if trace_size_in_mib > 400:
results.Fail('Trace size is too big: %s MiB' % trace_size_in_mib)
return
logging.warning('Starting to compute metrics on trace')
start = time.time()
mre_result = metric_runner.RunMetric(
filename, metrics, extra_import_options,
report_progress=False)
logging.warning('Processing resulting traces took %.3f seconds' % (
time.time() - start))
page = results.current_page
for f in mre_result.failures:
results.Fail(f.stack)
histogram_dicts = mre_result.pairs.get('histograms', [])
results.ImportHistogramDicts(histogram_dicts)
for d in mre_result.pairs.get('scalars', []):
results.AddValue(common_value_helpers.TranslateScalarValue(d, page))
def DidRunStory(self, platform, results):
"""Clean up after running the story."""
pass
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from contrib.cluster_telemetry import shared_browserless_story
from telemetry.page import traffic_setting as traffic_setting_module from telemetry.page import traffic_setting as traffic_setting_module
from telemetry.page import page as page_module from telemetry.page import page as page_module
...@@ -35,6 +36,27 @@ class CTPage(page_module.Page): ...@@ -35,6 +36,27 @@ class CTPage(page_module.Page):
self._run_page_interaction_callback(action_runner) self._run_page_interaction_callback(action_runner)
class LocalTracePath(story.Story):
def __init__(self, local_file_path, shared_state_class):
super(LocalTracePath, self).__init__(
shared_state_class=shared_state_class,
name=local_file_path)
def Run(self, shared_state):
pass
class CTBrowserLessPageSet(story.StorySet):
"""Page set used by CT Benchmarks that do not require a browser."""
def __init__(self, local_file_paths):
super(CTBrowserLessPageSet, self).__init__()
shared_state_class = shared_browserless_story.SharedBrowserlessStory
for local_file_path in local_file_paths.split(','):
self.AddStory(
LocalTracePath(
local_file_path=local_file_path,
shared_state_class=shared_state_class))
class CTPageSet(story.StorySet): class CTPageSet(story.StorySet):
"""Page set used by CT Benchmarks.""" """Page set used by CT Benchmarks."""
......
# Copyright 2018 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 telemetry import story as story_module
class SharedBrowserlessStory(story_module.SharedState):
"""
This class subclasses story_module.SharedState and removes all logic required
to bring up a browser that is found in shared_page_state.SharedPageState.
"""
def __init__(self, test, finder_options, story_set):
super(SharedBrowserlessStory, self).__init__(
test, finder_options, story_set)
@property
def platform(self):
return None
def WillRunStory(self, unused_page):
return
def DidRunStory(self, results):
return
def CanRunStory(self, unused_page):
return True
def RunStory(self, results):
return
def TearDownState(self):
pass
def DumpStateUponFailure(self, story, results):
pass
...@@ -19,6 +19,7 @@ path_util.AddAndroidPylibToPath() ...@@ -19,6 +19,7 @@ path_util.AddAndroidPylibToPath()
def GetAllStorySets(): def GetAllStorySets():
story_sets = [] story_sets = []
benchmarks_to_skip = [ benchmarks_to_skip = [
'analysis_metrics_ct',
'skpicture_printer_ct', 'skpicture_printer_ct',
'screenshot_ct', 'screenshot_ct',
'smoothness_ct', 'smoothness_ct',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment