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( |