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

Unified Diff: telemetry/telemetry/internal/results/html2_output_formatter.py

Issue 2474573002: Convert chart-json to Histograms. (Closed)
Patch Set: . Created 4 years, 1 month 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 | « no previous file | telemetry/telemetry/internal/results/html_output_formatter.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: telemetry/telemetry/internal/results/html2_output_formatter.py
diff --git a/telemetry/telemetry/internal/results/html2_output_formatter.py b/telemetry/telemetry/internal/results/html2_output_formatter.py
index 7935265d30cc8548d9bac32ba87632ff7b50ef9d..735c9652b1310af814aad2e020abe1ffbc40a31d 100644
--- a/telemetry/telemetry/internal/results/html2_output_formatter.py
+++ b/telemetry/telemetry/internal/results/html2_output_formatter.py
@@ -3,27 +3,52 @@
# found in the LICENSE file.
import datetime
+import json
import logging
import os
+import tempfile
from py_utils import cloud_storage
+from telemetry.internal.results import chart_json_output_formatter
from telemetry.internal.results import output_formatter
from tracing import results_renderer
+from tracing.value import convert_chart_json
class Html2OutputFormatter(output_formatter.OutputFormatter):
- _JSON_TAG = '<div id="value-set-json">%s</div>'
-
- def __init__(self, output_stream, reset_results, upload_results):
+ def __init__(self, output_stream, metadata, reset_results, upload_results):
super(Html2OutputFormatter, self).__init__(output_stream)
+ self._metadata = metadata
self._upload_results = upload_results
self._reset_results = reset_results
+ def ConvertChartJson_(self, page_test_results):
+ chart_json = chart_json_output_formatter.ResultsAsChartDict(
+ self._metadata, page_test_results.all_page_specific_values,
+ page_test_results.all_summary_values)
+ file_descriptor, chart_json_path = tempfile.mkstemp()
+ os.close(file_descriptor)
+ json.dump(chart_json, file(chart_json_path, 'w'))
+
+ vinn_result = convert_chart_json.ConvertChartJson(chart_json_path)
+
+ os.remove(chart_json_path)
+
+ if vinn_result.returncode != 0:
+ logging.error('Error converting chart json to Histograms:\n' +
+ vinn_result.stdout)
+ return []
+ return json.loads(vinn_result.stdout)
+
def Format(self, page_test_results):
- results_renderer.RenderHTMLView(page_test_results.value_set,
- self._output_stream, self._reset_results)
+ histograms = page_test_results.value_set
+ if not histograms:
+ histograms = self.ConvertChartJson_(page_test_results)
+
+ results_renderer.RenderHTMLView(histograms,
+ self._output_stream, self._reset_results)
file_path = os.path.abspath(self._output_stream.name)
if self._upload_results:
remote_path = ('html-results/results-%s' %
« no previous file with comments | « no previous file | telemetry/telemetry/internal/results/html_output_formatter.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698