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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 if (resolved) { 962 if (resolved) {
963 processedStack.push(resolved.entry.codeId, resolved.offset); 963 processedStack.push(resolved.entry.codeId, resolved.offset);
964 } else { 964 } else {
965 processedStack.push(-1, stack[i]); 965 processedStack.push(-1, stack[i]);
966 } 966 }
967 } 967 }
968 this.ticks_.push({ tm : time_ns, vm : vmState, s : processedStack }); 968 this.ticks_.push({ tm : time_ns, vm : vmState, s : processedStack });
969 }; 969 };
970 970
971 JsonProfile.prototype.writeJson = function() { 971 JsonProfile.prototype.writeJson = function() {
972 var toplevel = { 972 // Write out the JSON in a partially manual way to avoid creating too-large
973 code : this.codeEntries_, 973 // strings in one JSON.stringify call when there are a lot of ticks.
974 functions : this.functionEntries_, 974 write('{\n')
975 ticks : this.ticks_ 975 write(' "code": ' + JSON.stringify(this.codeEntries_) + ',\n');
976 }; 976 write(' "functions": ' + JSON.stringify(this.functionEntries_) + ',\n');
977 write(JSON.stringify(toplevel)); 977 write(' "ticks": [\n');
978 for (var i = 0; i < this.ticks_.length; i++) {
979 write(' ' + JSON.stringify(this.ticks_[i]));
980 if (i < this.ticks_.length - 1) {
981 write(',\n');
982 } else {
983 write('\n');
984 }
985 }
986 write(' ]\n');
987 write('}\n');
978 }; 988 };
OLDNEW
« 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