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

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

Issue 2089833002: Entry point for bisect sample comparison. (Closed) Base URL: https://github.com/catapult-project/catapult.git@mann
Patch Set: Adding tests that pass 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 side-by-side diff with in-line comments
Download patch
Index: tracing/tracing/metrics/compare_samples.py
diff --git a/tracing/tracing/metrics/compare_samples.py b/tracing/tracing/metrics/compare_samples.py
new file mode 100644
index 0000000000000000000000000000000000000000..75d03b027bade7f7b2efe3b1b583e176f45eca42
--- /dev/null
+++ b/tracing/tracing/metrics/compare_samples.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# Copyright (c) 2015 The Chromium Authors. All rights reserved.
eakuefner 2016/07/21 19:35:34 nit: no c
RobertoCN 2016/09/02 21:19:30 Done.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import argparse
+import sys
+import tempfile
+
+import tracing_project
+import vinn
+
+
+def CompareSamples(sample_a, sample_b, metric, method='compareCharts'):
+ project = tracing_project.TracingProject()
+ temp_out = tempfile.TemporaryFile()
+
+ cmd = """
+ HTMLImportsLoader.loadHTML('/tracing/metrics/compare_samples.html');
+ var results = tr.metrics.BisectComparison.%s('%s', '%s', '%s');
+ console.log(JSON.stringify(results));
+ """ % (method, sample_a, sample_b, metric)
+ try:
+ res = vinn.RunJsString(
+ cmd, source_paths=list(project.source_paths),
+ stdout=temp_out)
+ except:
+ temp_out.seek(0)
+ print temp_out.read() # Stack trace gets dumped here.
+ raise
+ temp_out.seek(0)
+ return res.returncode, temp_out.read()
+
+
+def Main(argv):
+ parser = argparse.ArgumentParser(
+ description='Compare samples.')
+ parser.add_argument('sample_a', type=str,
+ help='comma-separated list of paths to valuesets from '
+ 'sample a')
eakuefner 2016/07/21 19:35:34 nit: should be indented with the first ' above
RobertoCN 2016/09/02 21:19:30 Done.
+ parser.add_argument('sample_b', type=str,
+ help='comma-separated list of paths to valuesets from '
+ 'sample b')
+ parser.add_argument('metric', type=str,
+ help='name of the metric to compare')
+ args = parser.parse_args(argv[1:])
+
+ error_code, output = CompareSamples(args.sample_a, args.sample_b, args.metric)
+ print output
+ sys.exit(error_code)

Powered by Google App Engine
This is Rietveld 408576698