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

Side by Side Diff: tools/profviz/composer.js

Issue 23736004: Add better consistency check and error output to plot script. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « tools/plot-timer-events ('k') | tools/profviz/profviz.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 Array.prototype.top = function() { 28 Array.prototype.top = function() {
29 if (this.length == 0) return undefined; 29 if (this.length == 0) return undefined;
30 return this[this.length - 1]; 30 return this[this.length - 1];
31 } 31 }
32 32
33 33
34 function PlotScriptComposer(kResX, kResY) { 34 function PlotScriptComposer(kResX, kResY, error_output) {
35 // Constants. 35 // Constants.
36 var kV8BinarySuffixes = ["/d8", "/libv8.so"]; 36 var kV8BinarySuffixes = ["/d8", "/libv8.so"];
37 var kStackFrames = 8; // Stack frames to display in the plot. 37 var kStackFrames = 8; // Stack frames to display in the plot.
38 38
39 var kTimerEventWidth = 0.33; // Width of each timeline. 39 var kTimerEventWidth = 0.33; // Width of each timeline.
40 var kExecutionFrameWidth = 0.2; // Width of the top stack frame line. 40 var kExecutionFrameWidth = 0.2; // Width of the top stack frame line.
41 var kStackFrameWidth = 0.1; // Width of the lower stack frame lines. 41 var kStackFrameWidth = 0.1; // Width of the lower stack frame lines.
42 var kGapWidth = 0.05; // Gap between stack frame lines. 42 var kGapWidth = 0.05; // Gap between stack frame lines.
43 43
44 var kY1Offset = 11; // Offset for stack frame vs. event lines. 44 var kY1Offset = 11; // Offset for stack frame vs. event lines.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 143
144 var range_start = undefined; 144 var range_start = undefined;
145 var range_end = undefined; 145 var range_end = undefined;
146 var obj_index = 0; 146 var obj_index = 0;
147 var pause_tolerance = 0.005; // Milliseconds. 147 var pause_tolerance = 0.005; // Milliseconds.
148 var distortion = 0; 148 var distortion = 0;
149 149
150 // Utility functions. 150 // Utility functions.
151 function assert(something, message) { 151 function assert(something, message) {
152 if (!something) print(new Error(message).stack); 152 if (!something) {
153 var error = new Error(message);
154 error_output(error.stack);
155 }
153 } 156 }
154 157
155 function FindCodeKind(kind) { 158 function FindCodeKind(kind) {
156 for (name in CodeKinds) { 159 for (name in CodeKinds) {
157 if (CodeKinds[name].kinds.indexOf(kind) >= 0) { 160 if (CodeKinds[name].kinds.indexOf(kind) >= 0) {
158 return CodeKinds[name]; 161 return CodeKinds[name];
159 } 162 }
160 } 163 }
161 } 164 }
162 165
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 result.push(new Range(Math.max(ranges[i].start, start), 204 result.push(new Range(Math.max(ranges[i].start, start),
202 Math.min(ranges[i].end, end))); 205 Math.min(ranges[i].end, end)));
203 } 206 }
204 } 207 }
205 return result; 208 return result;
206 } 209 }
207 210
208 // Public methods. 211 // Public methods.
209 this.collectData = function(input, distortion_per_entry) { 212 this.collectData = function(input, distortion_per_entry) {
210 213
214 var last_timestamp = 0;
215
211 // Parse functions. 216 // Parse functions.
212 var parseTimeStamp = function(timestamp) { 217 var parseTimeStamp = function(timestamp) {
218 int_timestamp = parseInt(timestamp);
219 assert(int_timestamp >= last_timestamp, "Inconsistent timestamps.");
220 last_timestamp = int_timestamp;
213 distortion += distortion_per_entry; 221 distortion += distortion_per_entry;
214 return parseInt(timestamp) / 1000 - distortion; 222 return int_timestamp / 1000 - distortion;
215 } 223 }
216 224
217 var processTimerEventStart = function(name, start) { 225 var processTimerEventStart = function(name, start) {
218 // Find out the thread id. 226 // Find out the thread id.
219 var new_event = TimerEvents[name]; 227 var new_event = TimerEvents[name];
220 if (new_event === undefined) return; 228 if (new_event === undefined) return;
221 var thread_id = new_event.thread_id; 229 var thread_id = new_event.thread_id;
222 230
223 start = Math.max(last_time_stamp[thread_id] + kMinRangeLength, start); 231 start = Math.max(last_time_stamp[thread_id] + kMinRangeLength, start);
224 232
(...skipping 28 matching lines...) Expand all
253 }; 261 };
254 262
255 var processCodeMoveEvent = function(from, to) { 263 var processCodeMoveEvent = function(from, to) {
256 code_map.moveCode(from, to); 264 code_map.moveCode(from, to);
257 }; 265 };
258 266
259 var processCodeDeleteEvent = function(address) { 267 var processCodeDeleteEvent = function(address) {
260 code_map.deleteCode(address); 268 code_map.deleteCode(address);
261 }; 269 };
262 270
263 var processSharedLibrary = function(name, start, end) {
264 var code_entry = new CodeMap.CodeEntry(end - start, name);
265 code_entry.kind = -2; // External code kind.
266 for (var i = 0; i < kV8BinarySuffixes.length; i++) {
267 var suffix = kV8BinarySuffixes[i];
268 if (name.indexOf(suffix, name.length - suffix.length) >= 0) {
269 code_entry.kind = -1; // V8 runtime code kind.
270 break;
271 }
272 }
273 code_map.addLibrary(start, code_entry);
274 };
275
276 var processTimerEventStart = function(name, start) {
277 // Find out the thread id.
278 var new_event = TimerEvents[name];
279 if (new_event === undefined) return;
280 var thread_id = new_event.thread_id;
281
282 start = Math.max(last_time_stamp[thread_id] + kMinRangeLength, start);
283
284 // Last event on this thread is done with the start of this event.
285 var last_event = event_stack[thread_id].top();
286 if (last_event !== undefined) {
287 var new_range = new Range(last_time_stamp[thread_id], start);
288 last_event.ranges.push(new_range);
289 }
290 event_stack[thread_id].push(new_event);
291 last_time_stamp[thread_id] = start;
292 };
293
294 var processTimerEventEnd = function(name, end) {
295 // Find out about the thread_id.
296 var finished_event = TimerEvents[name];
297 var thread_id = finished_event.thread_id;
298 assert(finished_event === event_stack[thread_id].pop(),
299 "inconsistent event stack");
300
301 end = Math.max(last_time_stamp[thread_id] + kMinRangeLength, end);
302
303 var new_range = new Range(last_time_stamp[thread_id], end);
304 finished_event.ranges.push(new_range);
305 last_time_stamp[thread_id] = end;
306 };
307
308 var processCodeCreateEvent = function(type, kind, address, size, name) {
309 var code_entry = new CodeMap.CodeEntry(size, name);
310 code_entry.kind = kind;
311 code_map.addCode(address, code_entry);
312 };
313
314 var processCodeMoveEvent = function(from, to) {
315 code_map.moveCode(from, to);
316 };
317
318 var processCodeDeleteEvent = function(address) {
319 code_map.deleteCode(address);
320 };
321
322 var processCodeDeoptEvent = function(time, size) { 271 var processCodeDeoptEvent = function(time, size) {
323 deopts.push(new Deopt(time, size)); 272 deopts.push(new Deopt(time, size));
324 } 273 }
325 274
326 var processSharedLibrary = function(name, start, end) { 275 var processSharedLibrary = function(name, start, end) {
327 var code_entry = new CodeMap.CodeEntry(end - start, name); 276 var code_entry = new CodeMap.CodeEntry(end - start, name);
328 code_entry.kind = -3; // External code kind. 277 code_entry.kind = -3; // External code kind.
329 for (var i = 0; i < kV8BinarySuffixes.length; i++) { 278 for (var i = 0; i < kV8BinarySuffixes.length; i++) {
330 var suffix = kV8BinarySuffixes[i]; 279 var suffix = kV8BinarySuffixes[i];
331 if (name.indexOf(suffix, name.length - suffix.length) >= 0) { 280 if (name.indexOf(suffix, name.length - suffix.length) >= 0) {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 output("plot '-' using 1:2 axes x1y2 with impulses ls 1"); 520 output("plot '-' using 1:2 axes x1y2 with impulses ls 1");
572 for (var i = 0; i < execution_pauses.length; i++) { 521 for (var i = 0; i < execution_pauses.length; i++) {
573 var pause = execution_pauses[i]; 522 var pause = execution_pauses[i];
574 output(pause.end + " " + pause.duration()); 523 output(pause.end + " " + pause.duration());
575 obj_index++; 524 obj_index++;
576 } 525 }
577 output("e"); 526 output("e");
578 return obj_index; 527 return obj_index;
579 }; 528 };
580 } 529 }
OLDNEW
« no previous file with comments | « tools/plot-timer-events ('k') | tools/profviz/profviz.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698