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

Unified Diff: tracing/tracing/results_renderer.py

Issue 2528113003: Revert of 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 | « tracing/tracing/results2_template.html ('k') | tracing/tracing/results_renderer_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/results_renderer.py
diff --git a/tracing/tracing/results_renderer.py b/tracing/tracing/results_renderer.py
index 9403a81eb718e205566424145dd7423b732f09e2..5b3605dfc58743d76d6739b1f59a04013a0d083c 100644
--- a/tracing/tracing/results_renderer.py
+++ b/tracing/tracing/results_renderer.py
@@ -14,24 +14,28 @@
_JSON_TAG = '<histogram-json>%s</histogram-json>'
-def ExtractJSON(results_html, json_tag):
- results = []
+def ExtractJSON(results_html, json_tag=_JSON_TAG):
+ histograms = []
pattern = '(.*?)'.join(re.escape(part) for part in json_tag.split('%s'))
flags = re.MULTILINE | re.DOTALL
for match in re.finditer(pattern, results_html, flags):
try:
- results.append(json.loads(match.group(1)))
+ histograms.append(json.loads(match.group(1)))
except ValueError:
logging.warn('Found existing results json, but failed to parse it.')
return []
- return results
+ return histograms
def ReadExistingResults(results_html):
+ if not isinstance(results_html, basestring):
+ results_html.seek(0)
+ results_html = results_html.read()
+
if not results_html:
return []
- histograms = ExtractJSON(results_html, _JSON_TAG)
+ histograms = ExtractJSON(results_html)
# Fall-back to old formats.
if not histograms:
@@ -49,12 +53,9 @@
def RenderHTMLView(histograms, output_stream, reset_results=False):
+ if not reset_results:
+ histograms += ReadExistingResults(output_stream)
output_stream.seek(0)
-
- if not reset_results:
- results_html = output_stream.read()
- output_stream.seek(0)
- histograms += ReadExistingResults(results_html)
vulcanizer = tracing_project.TracingProject().CreateVulcanizer()
load_sequence = vulcanizer.CalcLoadSequenceForModuleNames(
« no previous file with comments | « tracing/tracing/results2_template.html ('k') | tracing/tracing/results_renderer_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698