OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 'reg.exp. ': new CodeKind("#0000FF", [-2]), | 87 'reg.exp. ': new CodeKind("#0000FF", [-2]), |
88 'runtime ': new CodeKind("#000000", [-1]), | 88 'runtime ': new CodeKind("#000000", [-1]), |
89 'full code': new CodeKind("#DD0000", [0]), | 89 'full code': new CodeKind("#DD0000", [0]), |
90 'opt code ': new CodeKind("#00EE00", [1]), | 90 'opt code ': new CodeKind("#00EE00", [1]), |
91 'code stub': new CodeKind("#FF00FF", [2]), | 91 'code stub': new CodeKind("#FF00FF", [2]), |
92 'built-in ': new CodeKind("#AA00AA", [3]), | 92 'built-in ': new CodeKind("#AA00AA", [3]), |
93 'inl.cache': new CodeKind("#4444AA", [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]), | 93 'inl.cache': new CodeKind("#4444AA", [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]), |
94 } | 94 } |
95 | 95 |
96 | 96 |
97 var xrange_start = Infinity; | 97 var xrange_start; |
98 var xrange_end = 0; | 98 var xrange_end; |
99 var obj_index = 0; | 99 var obj_index = 0; |
100 var execution_pauses = []; | 100 var execution_pauses = []; |
101 var code_map = new CodeMap(); | 101 var code_map = new CodeMap(); |
102 | 102 |
103 var xrange_start_override = undefined; | 103 var xrange_start_override = undefined; |
104 var xrange_end_override = undefined; | 104 var xrange_end_override = undefined; |
105 var distortion_per_entry = 0.005; // Milliseconds | 105 var distortion_per_entry = 0.005; // Milliseconds |
106 | 106 |
107 var sort_by_start = []; | 107 var sort_by_start = []; |
108 var sort_by_end = []; | 108 var sort_by_end = []; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 // Make sure that start <= end applies for every range. | 261 // Make sure that start <= end applies for every range. |
262 for (name in TimerEvents) { | 262 for (name in TimerEvents) { |
263 var ranges = TimerEvents[name].ranges; | 263 var ranges = TimerEvents[name].ranges; |
264 for (var j = 0; j < ranges.length; j++) { | 264 for (var j = 0; j < ranges.length; j++) { |
265 if (ranges[j].end < ranges[j].start) ranges[j].end = ranges[j].start; | 265 if (ranges[j].end < ranges[j].start) ranges[j].end = ranges[j].start; |
266 } | 266 } |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
270 | 270 |
| 271 function FindPlotRange() { |
| 272 var start_found = (xrange_start_override || xrange_start_override == 0); |
| 273 var end_found = (xrange_end_override || xrange_end_override == 0); |
| 274 xrange_start = start_found ? xrange_start_override : Infinity; |
| 275 xrange_end = end_found ? xrange_end_override : -Infinity; |
| 276 |
| 277 if (start_found && end_found) return; |
| 278 |
| 279 var execution_ranges = kExecutionEvent.ranges; |
| 280 for (var i = 0; i < execution_ranges.length; i++) { |
| 281 if (execution_ranges[i].start < xrange_start && !start_found) { |
| 282 xrange_start = execution_ranges[i].start; |
| 283 } |
| 284 if (execution_ranges[i].end > xrange_end && !end_found) { |
| 285 xrange_end = execution_ranges[i].end; |
| 286 } |
| 287 } |
| 288 |
| 289 for (codekind in CodeKinds) { |
| 290 var ticks = CodeKinds[codekind].in_execution; |
| 291 for (var i = 0; i < ticks.length; i++) { |
| 292 if (ticks[i].tick < xrange_start && !start_found) { |
| 293 xrange_start = ticks[i].tick; |
| 294 } |
| 295 if (ticks[i].tick > xrange_end && !end_found) { |
| 296 xrange_end = ticks[i].tick; |
| 297 } |
| 298 } |
| 299 } |
| 300 } |
| 301 |
| 302 |
271 function CollectData() { | 303 function CollectData() { |
272 // Collect data from log. | 304 // Collect data from log. |
273 var logreader = new LogReader( | 305 var logreader = new LogReader( |
274 { 'timer-event' : { parsers: [null, parseInt, parseInt], | 306 { 'timer-event' : { parsers: [null, parseInt, parseInt], |
275 processor: ProcessTimerEvent }, | 307 processor: ProcessTimerEvent }, |
276 'shared-library': { parsers: [null, parseInt, parseInt], | 308 'shared-library': { parsers: [null, parseInt, parseInt], |
277 processor: ProcessSharedLibrary }, | 309 processor: ProcessSharedLibrary }, |
278 'code-creation': { parsers: [null, parseInt, parseInt, parseInt, null], | 310 'code-creation': { parsers: [null, parseInt, parseInt, parseInt, null], |
279 processor: ProcessCodeCreateEvent }, | 311 processor: ProcessCodeCreateEvent }, |
280 'code-move': { parsers: [parseInt, parseInt], | 312 'code-move': { parsers: [parseInt, parseInt], |
281 processor: ProcessCodeMoveEvent }, | 313 processor: ProcessCodeMoveEvent }, |
282 'code-delete': { parsers: [parseInt], | 314 'code-delete': { parsers: [parseInt], |
283 processor: ProcessCodeDeleteEvent }, | 315 processor: ProcessCodeDeleteEvent }, |
284 'tick': { parsers: [parseInt, parseInt, parseInt, | 316 'tick': { parsers: [parseInt, parseInt, parseInt, |
285 null, null, parseInt, 'var-args'], | 317 null, null, parseInt, 'var-args'], |
286 processor: ProcessTickEvent }, | 318 processor: ProcessTickEvent }, |
287 'distortion': { parsers: [parseInt], | 319 'distortion': { parsers: [parseInt], |
288 processor: ProcessDistortion }, | 320 processor: ProcessDistortion }, |
289 'plot-range': { parsers: [parseInt, parseInt], | 321 'plot-range': { parsers: [parseInt, parseInt], |
290 processor: ProcessPlotRange }, | 322 processor: ProcessPlotRange }, |
291 }); | 323 }); |
292 | 324 |
293 var line; | 325 var line; |
294 while (line = readline()) { | 326 while (line = readline()) { |
295 logreader.processLogLine(line); | 327 logreader.processLogLine(line); |
296 } | 328 } |
297 | 329 |
298 Undistort(); | 330 Undistort(); |
299 | 331 |
300 // Figure out plot range. | |
301 var execution_ranges = kExecutionEvent.ranges; | |
302 for (var i = 0; i < execution_ranges.length; i++) { | |
303 if (execution_ranges[i].start < xrange_start) { | |
304 xrange_start = execution_ranges[i].start; | |
305 } | |
306 if (execution_ranges[i].end > xrange_end) { | |
307 xrange_end = execution_ranges[i].end; | |
308 } | |
309 } | |
310 | |
311 // Collect execution pauses. | 332 // Collect execution pauses. |
312 for (name in TimerEvents) { | 333 for (name in TimerEvents) { |
313 var event = TimerEvents[name]; | 334 var event = TimerEvents[name]; |
314 if (!event.pause) continue; | 335 if (!event.pause) continue; |
315 var ranges = event.ranges; | 336 var ranges = event.ranges; |
316 for (var j = 0; j < ranges.length; j++) execution_pauses.push(ranges[j]); | 337 for (var j = 0; j < ranges.length; j++) execution_pauses.push(ranges[j]); |
317 } | 338 } |
318 execution_pauses = MergeRanges(execution_pauses); | 339 execution_pauses = MergeRanges(execution_pauses); |
319 | 340 |
320 // Knock out time not spent in javascript execution. Note that this also | 341 // Knock out time not spent in javascript execution. Note that this also |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } else { | 480 } else { |
460 throw new Error("this should not happen!"); | 481 throw new Error("this should not happen!"); |
461 } | 482 } |
462 } | 483 } |
463 | 484 |
464 return result; | 485 return result; |
465 } | 486 } |
466 | 487 |
467 | 488 |
468 function GnuplotOutput() { | 489 function GnuplotOutput() { |
469 xrange_start = (xrange_start_override || xrange_start_override == 0) | 490 FindPlotRange(); |
470 ? xrange_start_override : xrange_start; | 491 |
471 xrange_end = (xrange_end_override || xrange_end_override == 0) | |
472 ? xrange_end_override : xrange_end; | |
473 print("set terminal pngcairo size " + kResX + "," + kResY + | 492 print("set terminal pngcairo size " + kResX + "," + kResY + |
474 " enhanced font 'Helvetica,10'"); | 493 " enhanced font 'Helvetica,10'"); |
475 print("set yrange [0:" + (num_timer_event + 1) + "]"); | 494 print("set yrange [0:" + (num_timer_event + 1) + "]"); |
476 print("set xlabel \"execution time in ms\""); | 495 print("set xlabel \"execution time in ms\""); |
477 print("set xrange [" + xrange_start + ":" + xrange_end + "]"); | 496 print("set xrange [" + xrange_start + ":" + xrange_end + "]"); |
478 print("set style fill pattern 2 bo 1"); | 497 print("set style fill pattern 2 bo 1"); |
479 print("set style rect fs solid 1 noborder"); | 498 print("set style rect fs solid 1 noborder"); |
480 print("set style line 1 lt 1 lw 1 lc rgb \"#000000\""); | 499 print("set style line 1 lt 1 lw 1 lc rgb \"#000000\""); |
481 print("set xtics out nomirror"); | 500 print("set xtics out nomirror"); |
482 print("unset key"); | 501 print("unset key"); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 for (var i = 0; i < execution_pauses.length; i++) { | 586 for (var i = 0; i < execution_pauses.length; i++) { |
568 var pause = execution_pauses[i]; | 587 var pause = execution_pauses[i]; |
569 print(pause.end + " " + pause.duration()); | 588 print(pause.end + " " + pause.duration()); |
570 } | 589 } |
571 print("e"); | 590 print("e"); |
572 } | 591 } |
573 | 592 |
574 | 593 |
575 CollectData(); | 594 CollectData(); |
576 GnuplotOutput(); | 595 GnuplotOutput(); |
OLD | NEW |