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

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

Issue 2538043005: Replace ValueSetOutputFormatter with HistogramSetJsonOutputFormatter. (Closed)
Patch Set: rebase Created 4 years 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/html2_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/histogram_set_json_output_formatter.py
diff --git a/telemetry/telemetry/internal/results/histogram_set_json_output_formatter.py b/telemetry/telemetry/internal/results/histogram_set_json_output_formatter.py
new file mode 100644
index 0000000000000000000000000000000000000000..6c6f397b498dc71dfcbd674834a94e1aed511b70
--- /dev/null
+++ b/telemetry/telemetry/internal/results/histogram_set_json_output_formatter.py
@@ -0,0 +1,28 @@
+# 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 json
+import logging
+
+from telemetry.internal.results import output_formatter
+
+
+class HistogramSetJsonOutputFormatter(output_formatter.OutputFormatter):
+ def __init__(self, output_stream, metadata, reset_results):
+ super(HistogramSetJsonOutputFormatter, self).__init__(output_stream)
+ self._metadata = metadata
+ self._reset_results = reset_results
+
+ def Format(self, page_test_results):
+ histograms = page_test_results.AsHistogramDicts(self._metadata)
+ self._output_stream.seek(0)
+ if not self._reset_results:
+ existing = self._output_stream.read()
+ self._output_stream.seek(0)
+ if existing:
+ try:
+ histograms += json.loads(existing)
+ except ValueError:
+ logging.warn('Found existing histograms json but failed to parse it.')
+ json.dump(histograms, self._output_stream)
« no previous file with comments | « no previous file | telemetry/telemetry/internal/results/html2_output_formatter.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698