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

Unified Diff: tracing/tracing/results_renderer.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 | « 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 5b3605dfc58743d76d6739b1f59a04013a0d083c..9403a81eb718e205566424145dd7423b732f09e2 100644
--- a/tracing/tracing/results_renderer.py
+++ b/tracing/tracing/results_renderer.py
@@ -14,28 +14,24 @@ from py_vulcanize import generate
_JSON_TAG = '<histogram-json>%s</histogram-json>'
-def ExtractJSON(results_html, json_tag=_JSON_TAG):
- histograms = []
+def ExtractJSON(results_html, json_tag):
+ results = []
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:
- histograms.append(json.loads(match.group(1)))
+ results.append(json.loads(match.group(1)))
except ValueError:
logging.warn('Found existing results json, but failed to parse it.')
return []
- return histograms
+ return results
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)
+ histograms = ExtractJSON(results_html, _JSON_TAG)
# Fall-back to old formats.
if not histograms:
@@ -53,10 +49,13 @@ def ReadExistingResults(results_html):
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(
['tracing.results2_template'])
« 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