Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: tracing/tracing/metrics/metric_runner.py

Issue 2162963002: [polymer] Merge of master into polymer10-migration (Closed) Base URL: git@github.com:catapult-project/catapult.git@polymer10-migration
Patch Set: Merge polymer10-migration int polymer10-merge Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import os 4 import os
5 5
6 from perf_insights.mre import function_handle 6 from perf_insights.mre import function_handle
7 from perf_insights.mre import map_runner 7 from perf_insights.mre import map_runner
8 from perf_insights.mre import progress_reporter 8 from perf_insights.mre import progress_reporter
9 from perf_insights.mre import file_handle 9 from perf_insights.mre import file_handle
10 from perf_insights.mre import job as job_module 10 from perf_insights.mre import job as job_module
11 11
12 _METRIC_MAP_FUNCTION_FILENAME = 'metric_map_function.html' 12 _METRIC_MAP_FUNCTION_FILENAME = 'metric_map_function.html'
13 13
14 _METRIC_MAP_FUNCTION_NAME = 'metricMapFunction' 14 _METRIC_MAP_FUNCTION_NAME = 'metricMapFunction'
15 15
16 def _GetMetricsDir(): 16 def _GetMetricsDir():
17 return os.path.dirname(os.path.abspath(__file__)) 17 return os.path.dirname(os.path.abspath(__file__))
18 18
19 def _GetMetricRunnerHandle(metric): 19 def _GetMetricRunnerHandle(metrics):
20 assert isinstance(metric, basestring) 20 assert isinstance(metrics, list)
21 for metric in metrics:
22 assert isinstance(metric, basestring)
21 metrics_dir = _GetMetricsDir() 23 metrics_dir = _GetMetricsDir()
22 metric_mapper_path = os.path.join(metrics_dir, _METRIC_MAP_FUNCTION_FILENAME) 24 metric_mapper_path = os.path.join(metrics_dir, _METRIC_MAP_FUNCTION_FILENAME)
23 25
24 modules_to_load = [function_handle.ModuleToLoad(filename=metric_mapper_path)] 26 modules_to_load = [function_handle.ModuleToLoad(filename=metric_mapper_path)]
25 options = {'metric': metric} 27 options = {'metrics': metrics}
26 map_function_handle = function_handle.FunctionHandle( 28 map_function_handle = function_handle.FunctionHandle(
27 modules_to_load, _METRIC_MAP_FUNCTION_NAME, options) 29 modules_to_load, _METRIC_MAP_FUNCTION_NAME, options)
28 30
29 return job_module.Job(map_function_handle, None) 31 return job_module.Job(map_function_handle, None)
30 32
31 def RunMetric(filename, metric, extra_import_options=None): 33 def RunMetric(filename, metrics, extra_import_options=None):
32 result = RunMetricOnTraces([filename], metric, extra_import_options) 34 result = RunMetricOnTraces([filename], metrics, extra_import_options)
33 return result[filename] 35 return result[filename]
34 36
35 def RunMetricOnTraces(filenames, metric, 37 def RunMetricOnTraces(filenames, metrics,
36 extra_import_options=None): 38 extra_import_options=None):
37 trace_handles = [ 39 trace_handles = [
38 file_handle.URLFileHandle(f, 'file://%s' % f) for f in filenames] 40 file_handle.URLFileHandle(f, 'file://%s' % f) for f in filenames]
39 job = _GetMetricRunnerHandle(metric) 41 job = _GetMetricRunnerHandle(metrics)
40 runner = map_runner.MapRunner( 42 runner = map_runner.MapRunner(
41 trace_handles, job, 43 trace_handles, job, extra_import_options=extra_import_options,
42 extra_import_options=extra_import_options,
43 progress_reporter=progress_reporter.ProgressReporter()) 44 progress_reporter=progress_reporter.ProgressReporter())
44 map_results = runner.RunMapper() 45 map_results = runner.RunMapper()
45 return map_results 46 return map_results
OLDNEW
« no previous file with comments | « tracing/tracing/metrics/metric_map_function_test.html ('k') | tracing/tracing/metrics/sample_metric.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698