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

Unified Diff: tools/profile.js

Issue 2754683002: [tools] Manually write JSON in profile.js to avoid huge strings (Closed)
Patch Set: Created 3 years, 9 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: tools/profile.js
diff --git a/tools/profile.js b/tools/profile.js
index 7d189e056717e4a43b6a09f4c8cab6d1704d675f..c04bed31f1f228ff32bfb908a02a0776f3efd99c 100644
--- a/tools/profile.js
+++ b/tools/profile.js
@@ -969,10 +969,20 @@ JsonProfile.prototype.recordTick = function(time_ns, vmState, stack) {
};
JsonProfile.prototype.writeJson = function() {
- var toplevel = {
- code : this.codeEntries_,
- functions : this.functionEntries_,
- ticks : this.ticks_
- };
- write(JSON.stringify(toplevel));
+ // Write out the JSON in a partially manual way to avoid creating too-large
+ // strings in one JSON.stringify call when there are a lot of ticks.
+ write('{\n')
+ write(' "code": ' + JSON.stringify(this.codeEntries_) + ',\n');
+ write(' "functions": ' + JSON.stringify(this.functionEntries_) + ',\n');
+ write(' "ticks": [\n');
+ for (var i = 0; i < this.ticks_.length; i++) {
+ write(' ' + JSON.stringify(this.ticks_[i]));
+ if (i < this.ticks_.length - 1) {
+ write(',\n');
+ } else {
+ write('\n');
+ }
+ }
+ write(' ]\n');
+ write('}\n');
};
« 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