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

Unified Diff: telemetry/telemetry/value/trace.py

Issue 2174543002: Optimize JSON dump in telemetry. (Closed) Base URL: git@github.com:catapult-project/catapult@master
Patch Set: add comment Created 4 years, 5 months 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: telemetry/telemetry/value/trace.py
diff --git a/telemetry/telemetry/value/trace.py b/telemetry/telemetry/value/trace.py
index df2113bf17d4d2414deef5495d8104b923b8e0eb..1104ce9a8ecc2005bc9a9d95629e6bc845f44380 100644
--- a/telemetry/telemetry/value/trace.py
+++ b/telemetry/telemetry/value/trace.py
@@ -49,7 +49,9 @@ class TraceValue(value_module.Value):
if isinstance(trace, basestring):
fp.write(trace)
elif isinstance(trace, dict) or isinstance(trace, list):
- json.dump(trace, fp)
+ # Creating the string using dumps and then writing it is
+ # ~5x faster than using json.dump().
nednguyen 2016/07/22 22:56:16 Event better if we never keep the dict/list form i
+ fp.write(json.dumps(trace))
else:
raise TypeError('Trace is of unknown type.')
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698