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

Unified Diff: tracing/tracing/metrics/metric_runner.py

Issue 1685683003: Implement Timeline Based Measurement v2 (Closed) Base URL: git@github.com:catapult-project/catapult.git@new_style_results
Patch Set: fix vinn tests Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tracing/tracing/metrics/metric_registry.html ('k') | tracing/tracing/metrics/sample_metric.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/metrics/metric_runner.py
diff --git a/tracing/tracing/metrics/metric_runner.py b/tracing/tracing/metrics/metric_runner.py
new file mode 100644
index 0000000000000000000000000000000000000000..44bbc9215bdec373dd4d7a63f14c35bf5db1df54
--- /dev/null
+++ b/tracing/tracing/metrics/metric_runner.py
@@ -0,0 +1,34 @@
+# Copyright 2016 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 os
+
+from perf_insights import map_single_trace
+from perf_insights import function_handle
+from perf_insights.mre import file_handle
+
+_METRIC_MAP_FUNCTION_FILENAME = 'metric_map_function.html'
+
+_METRIC_MAP_FUNCTION_NAME = 'metricMapFunction'
+
+def _GetMetricsDir():
+ return os.path.dirname(os.path.abspath(__file__))
+
+def _GetMetricRunnerHandle(metrics):
+ assert isinstance(metrics, list)
+ metrics_dir = _GetMetricsDir()
+ metric_paths = [os.path.join(metrics_dir, metric) for metric in metrics]
+ metric_mapper_path = os.path.join(metrics_dir, _METRIC_MAP_FUNCTION_FILENAME)
+ metric_paths.append(metric_mapper_path)
+
+ modules_to_load = [function_handle.ModuleToLoad(filename=path) for path in
+ metric_paths]
+
+ return function_handle.FunctionHandle(modules_to_load,
+ _METRIC_MAP_FUNCTION_NAME)
+
+def RunMetrics(filename, metrics):
+ th = file_handle.URLFileHandle(filename, 'file://' + filename)
+ result = map_single_trace.MapSingleTrace(th, _GetMetricRunnerHandle(metrics))
+
+ return result
« no previous file with comments | « tracing/tracing/metrics/metric_registry.html ('k') | tracing/tracing/metrics/sample_metric.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698