Commit bb908218 authored by Juan Antonio Navarro Perez's avatar Juan Antonio Navarro Perez Committed by Commit Bot

[tools/perf] Wiring up results_processor with Telemetry

This CL implements the basic API layer of the new results_processor,
exposing functions to create an argument parser, process options,
and finally process results.

Currently the results processor only supports the "none" output
format, still delegating all output formatting to Telemetry.

Depends on catapult CL:
https://chromium-review.googlesource.com/c/catapult/+/1718424

Bug: 928275
Change-Id: Ib65cf62eeb59a4ab515f963bfcc7cc3bbd1f13f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1692986
Commit-Queue: Juan Antonio Navarro Pérez <perezju@chromium.org>
Reviewed-by: default avatarCaleb Rouleau <crouleau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683116}
parent 7d925ea2
# Copyright 2019 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.
"""Entry point module to run benchmarks with Telemetry and process results.
This wires up together both the Telemetry command line and runner, responsible
of running stories and collecting artifacts (traces, logs, etc.), together with
the results_processor, responsible of processing such artifacts and e.g. run
metrics to produce various kinds of outputs (histograms, csv, results.html).
"""
from core import results_processor
from telemetry import command_line
def main(config):
options = command_line.ParseArgs(
environment=config,
results_arg_parser=results_processor.ArgumentParser())
results_processor.ProcessOptions(options)
command_line.RunCommand(options)
results_processor.ProcessResults(options)
# Copyright 2019 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.results_processor.processor import ArgumentParser
from core.results_processor.processor import ProcessOptions
from core.results_processor.processor import ProcessResults
# Copyright 2019 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.
"""Implements the interface of the results_processor module.
Provides functions to parse command line arguments, process options, and the
entry point to start the processing of results.
"""
import argparse
import os
from telemetry import command_line
from telemetry.core import util
from py_utils import cloud_storage
SUPPORTED_FORMATS = set(['none'])
ALL_SUPPORTED_FORMATS = sorted(
SUPPORTED_FORMATS.union(command_line.LEGACY_OUTPUT_FORMATS))
def ArgumentParser():
"""Create an ArgumentParser defining options required by the processor."""
parser = argparse.ArgumentParser(add_help=False)
group = parser.add_argument_group(title='Result processor options')
group.add_argument(
'--output-format', action='append', dest='output_formats',
metavar='FORMAT', choices=ALL_SUPPORTED_FORMATS,
help=' '.join([
'Output format to produce.',
'May be used multiple times to produce multiple outputs.',
'Avaliable formats: %s.' % ', '.join(ALL_SUPPORTED_FORMATS),
'Defaults to: html.']))
group.add_argument(
'--output-dir', default=util.GetBaseDir(), metavar='DIR_PATH',
help=' '.join([
'Path to a directory where to write output artifacts.',
'Default: %(default)s.']))
group.add_argument(
'--reset-results', action='store_true',
help='Remove any previous files in the output directory. The default '
'is to append to existing results.')
group.add_argument(
'--results-label', metavar='LABEL',
help='Label to identify the results generated by this run.')
group.add_argument(
'--upload-results', action='store_true',
help='Upload generated artifacts to cloud storage.')
group.add_argument(
'--upload-bucket', default='output', metavar='BUCKET',
help=' '.join([
'Storage bucket to use for uploading artifacts.',
'Supported values are: %s; or a valid cloud storage bucket name.'
% ', '.join(cloud_storage.BUCKET_ALIAS_NAMES),
'Defaults to: %(default)s.']))
group.set_defaults(legacy_output_formats=[])
return parser
def ProcessOptions(options):
"""Adjust result processing options as needed before running benchmarks.
Note: The intended scope of this function is limited to only adjust options
defined by the ArgumentParser above. One should not attempt to read or modify
any other attributes that the options object may have.
Currently the main job of this function is to tease out and separate output
formats to be handled by the results processor, from those that should fall
back to the legacy output formatters in Telemetry.
Args:
options: An options object with values parsed from the command line.
"""
if not hasattr(options, 'output_formats'):
return
options.output_dir = os.path.expanduser(options.output_dir)
if options.upload_results:
options.upload_bucket = cloud_storage.BUCKET_ALIASES.get(
options.upload_bucket, options.upload_bucket)
else:
options.upload_bucket = None
chosen_formats = options.output_formats
if not chosen_formats:
chosen_formats = ['html']
options.output_formats = []
for output_format in chosen_formats:
if output_format == 'none':
continue
elif output_format in SUPPORTED_FORMATS:
options.output_formats.append(output_format)
else:
options.legacy_output_formats.append(output_format)
def ProcessResults(options):
"""Process intermediate results and produce the requested outputs.
This function takes the intermediate results generated by Telemetry after
running benchmarks (including artifacts such as traces, etc.), and processes
them as requested by the result processing options.
Args:
options: An options object with values parsed from the command line and
after any adjustments from ProcessOptions were applied.
"""
if not getattr(options, 'output_formats', None):
return
raise NotImplementedError(options.output_formats)
......@@ -8,9 +8,8 @@ import sys
from core import path_util
sys.path.insert(1, path_util.GetTelemetryDir())
from telemetry import benchmark_runner
from chrome_telemetry_build import chromium_config
from core import benchmark_runner
def main():
......
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