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

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: Removed stray line. Created 4 years, 3 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..0f7f76ce78d680144c932960f7d70765e9c26bc1
--- /dev/null
+++ b/tracing/tracing/metrics/compare_samples.py
@@ -0,0 +1,37 @@
+# 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 tempfile
+
+import tracing_project
+import vinn
+
+FORMAT_TO_METHOD = {
+ 'chartjson': 'compareCharts',
+ 'valueset': 'compareValuesets',
+ 'buildbot': 'compareBuildbotOutputs'
+}
+
+def CompareSamples(sample_a, sample_b, metric, data_format='chartjson'):
dtu 2016/09/15 21:31:56 Please docstring :)
RobertoCN 2016/09/19 20:07:43 Done.
+ method = FORMAT_TO_METHOD[data_format]
+ 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)
dtu 2016/09/15 21:31:56 I think the default behavior is to stick the stdou
RobertoCN 2016/09/19 20:07:43 Done.
+ 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()
dtu 2016/09/15 21:31:56 If someone is using this as a library, this return
RobertoCN 2016/09/19 20:07:43 Done.
+
+

Powered by Google App Engine
This is Rietveld 408576698