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..d8341d0b333975c7770e5bec488200ea2ff840b6 |
--- /dev/null |
+++ b/tracing/tracing/metrics/compare_samples.py |
@@ -0,0 +1,32 @@ |
+# 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 |
+ |
+ |
+def CompareSamples(sample_a, sample_b, metric, data_format='chartjson'): |
+ method = 'compareCharts' if data_format == 'chartjson' else 'compareValuesets' |
+ 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: |
RobertoCN
2016/09/01 19:28:23
loop ned in about the potential exceptions risen f
RobertoCN
2016/09/02 21:19:31
Adding him as reviewer.
|
+ res = vinn.RunJsString( |
+ cmd, source_paths=list(project.source_paths), |
+ stdout=temp_out) |
+ except: |
benjhayden
2016/08/10 17:40:21
What types of exceptions can be caught here?
|
+ temp_out.seek(0) |
+ print temp_out.read() # Stack trace gets dumped here. |
+ raise |
benjhayden
2016/08/10 17:40:21
Can you raise a specific type of exception?
|
+ temp_out.seek(0) |
+ return res.returncode, temp_out.read() |
+ |
+ |