| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 if (entry) FindCodeKind(entry.kind).in_execution.push(tick); | 225 if (entry) FindCodeKind(entry.kind).in_execution.push(tick); |
| 226 | 226 |
| 227 for (var i = 0; i < kStackFrames; i++) { | 227 for (var i = 0; i < kStackFrames; i++) { |
| 228 if (!stack[i]) break; | 228 if (!stack[i]) break; |
| 229 var entry = code_map.findEntry(stack[i]); | 229 var entry = code_map.findEntry(stack[i]); |
| 230 if (entry) FindCodeKind(entry.kind).stack_frames[i].push(tick); | 230 if (entry) FindCodeKind(entry.kind).stack_frames[i].push(tick); |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 | 233 |
| 234 | 234 |
| 235 function ProcessDistortion(distortion_in_picoseconds) { | |
| 236 distortion_per_entry = distortion_in_picoseconds / 1000000; | |
| 237 } | |
| 238 | |
| 239 | |
| 240 function ProcessPlotRange(start, end) { | |
| 241 xrange_start_override = start; | |
| 242 xrange_end_override = end; | |
| 243 } | |
| 244 | |
| 245 | |
| 246 function FindPlotRange() { | 235 function FindPlotRange() { |
| 247 var start_found = (xrange_start_override || xrange_start_override == 0); | 236 var start_found = (xrange_start_override || xrange_start_override == 0); |
| 248 var end_found = (xrange_end_override || xrange_end_override == 0); | 237 var end_found = (xrange_end_override || xrange_end_override == 0); |
| 249 xrange_start = start_found ? xrange_start_override : Infinity; | 238 xrange_start = start_found ? xrange_start_override : Infinity; |
| 250 xrange_end = end_found ? xrange_end_override : -Infinity; | 239 xrange_end = end_found ? xrange_end_override : -Infinity; |
| 251 | 240 |
| 252 if (start_found && end_found) return; | 241 if (start_found && end_found) return; |
| 253 | 242 |
| 254 for (name in TimerEvents) { | 243 for (name in TimerEvents) { |
| 255 var ranges = TimerEvents[name].ranges; | 244 var ranges = TimerEvents[name].ranges; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 280 pause_tolerance = (xrange_end - xrange_start) / kResX / 10; | 269 pause_tolerance = (xrange_end - xrange_start) / kResX / 10; |
| 281 } | 270 } |
| 282 | 271 |
| 283 | 272 |
| 284 function parseTimeStamp(timestamp) { | 273 function parseTimeStamp(timestamp) { |
| 285 distortion += distortion_per_entry; | 274 distortion += distortion_per_entry; |
| 286 return parseInt(timestamp) / 1000 - distortion; | 275 return parseInt(timestamp) / 1000 - distortion; |
| 287 } | 276 } |
| 288 | 277 |
| 289 | 278 |
| 279 function ParseArguments(args) { |
| 280 var processor = new ArgumentsProcessor(args); |
| 281 do { |
| 282 if (!processor.parse()) break; |
| 283 var result = processor.result(); |
| 284 var distortion = parseInt(result.distortion); |
| 285 if (isNaN(distortion)) break; |
| 286 // Convert picoseconds to milliseconds. |
| 287 distortion_per_entry = distortion / 1000000; |
| 288 var rangelimits = result.range.split(","); |
| 289 var range_start = parseInt(rangelimits[0]); |
| 290 var range_end = parseInt(rangelimits[1]); |
| 291 xrange_start_override = isNaN(range_start) ? undefined : range_start; |
| 292 xrange_end_override = isNaN(range_end) ? undefined : range_end; |
| 293 return; |
| 294 } while (false); |
| 295 processor.printUsageAndExit(); |
| 296 } |
| 297 |
| 298 |
| 290 function CollectData() { | 299 function CollectData() { |
| 291 // Collect data from log. | 300 // Collect data from log. |
| 292 var logreader = new LogReader( | 301 var logreader = new LogReader( |
| 293 { 'timer-event-start': { parsers: [null, parseTimeStamp], | 302 { 'timer-event-start': { parsers: [null, parseTimeStamp], |
| 294 processor: ProcessTimerEventStart }, | 303 processor: ProcessTimerEventStart }, |
| 295 'timer-event-end': { parsers: [null, parseTimeStamp], | 304 'timer-event-end': { parsers: [null, parseTimeStamp], |
| 296 processor: ProcessTimerEventEnd }, | 305 processor: ProcessTimerEventEnd }, |
| 297 'shared-library': { parsers: [null, parseInt, parseInt], | 306 'shared-library': { parsers: [null, parseInt, parseInt], |
| 298 processor: ProcessSharedLibrary }, | 307 processor: ProcessSharedLibrary }, |
| 299 'code-creation': { parsers: [null, parseInt, parseInt, parseInt, null], | 308 'code-creation': { parsers: [null, parseInt, parseInt, parseInt, null], |
| 300 processor: ProcessCodeCreateEvent }, | 309 processor: ProcessCodeCreateEvent }, |
| 301 'code-move': { parsers: [parseInt, parseInt], | 310 'code-move': { parsers: [parseInt, parseInt], |
| 302 processor: ProcessCodeMoveEvent }, | 311 processor: ProcessCodeMoveEvent }, |
| 303 'code-delete': { parsers: [parseInt], | 312 'code-delete': { parsers: [parseInt], |
| 304 processor: ProcessCodeDeleteEvent }, | 313 processor: ProcessCodeDeleteEvent }, |
| 305 'tick': { parsers: [parseInt, parseInt, parseTimeStamp, | 314 'tick': { parsers: [parseInt, parseInt, parseTimeStamp, |
| 306 null, null, parseInt, 'var-args'], | 315 null, null, parseInt, 'var-args'], |
| 307 processor: ProcessTickEvent }, | 316 processor: ProcessTickEvent } |
| 308 'distortion': { parsers: [parseInt], | |
| 309 processor: ProcessDistortion }, | |
| 310 'plot-range': { parsers: [parseInt, parseInt], | |
| 311 processor: ProcessPlotRange }, | |
| 312 }); | 317 }); |
| 313 | 318 |
| 314 var line; | 319 var line; |
| 315 while (line = readline()) { | 320 while (line = readline()) { |
| 316 logreader.processLogLine(line); | 321 logreader.processLogLine(line); |
| 317 } | 322 } |
| 318 | 323 |
| 319 // Collect execution pauses. | 324 // Collect execution pauses. |
| 320 for (name in TimerEvents) { | 325 for (name in TimerEvents) { |
| 321 var event = TimerEvents[name]; | 326 var event = TimerEvents[name]; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 if (ranges[i].start <= end && ranges[i].end >= start) { | 383 if (ranges[i].start <= end && ranges[i].end >= start) { |
| 379 result.push(new Range(Math.max(ranges[i].start, start), | 384 result.push(new Range(Math.max(ranges[i].start, start), |
| 380 Math.min(ranges[i].end, end))); | 385 Math.min(ranges[i].end, end))); |
| 381 } | 386 } |
| 382 } | 387 } |
| 383 return result; | 388 return result; |
| 384 } | 389 } |
| 385 | 390 |
| 386 | 391 |
| 387 function GnuplotOutput() { | 392 function GnuplotOutput() { |
| 388 FindPlotRange(); | |
| 389 | |
| 390 print("set terminal pngcairo size " + kResX + "," + kResY + | 393 print("set terminal pngcairo size " + kResX + "," + kResY + |
| 391 " enhanced font 'Helvetica,10'"); | 394 " enhanced font 'Helvetica,10'"); |
| 392 print("set yrange [0:" + (num_timer_event + 1) + "]"); | 395 print("set yrange [0:" + (num_timer_event + 1) + "]"); |
| 393 print("set xlabel \"execution time in ms\""); | 396 print("set xlabel \"execution time in ms\""); |
| 394 print("set xrange [" + xrange_start + ":" + xrange_end + "]"); | 397 print("set xrange [" + xrange_start + ":" + xrange_end + "]"); |
| 395 print("set style fill pattern 2 bo 1"); | 398 print("set style fill pattern 2 bo 1"); |
| 396 print("set style rect fs solid 1 noborder"); | 399 print("set style rect fs solid 1 noborder"); |
| 397 print("set style line 1 lt 1 lw 1 lc rgb \"#000000\""); | 400 print("set style line 1 lt 1 lw 1 lc rgb \"#000000\""); |
| 398 print("set xtics out nomirror"); | 401 print("set xtics out nomirror"); |
| 399 print("unset key"); | 402 print("unset key"); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 // Plot graph with impulses as data set. | 497 // Plot graph with impulses as data set. |
| 495 print("plot '-' using 1:2 axes x1y2 with impulses ls 1"); | 498 print("plot '-' using 1:2 axes x1y2 with impulses ls 1"); |
| 496 for (var i = 0; i < execution_pauses.length; i++) { | 499 for (var i = 0; i < execution_pauses.length; i++) { |
| 497 var pause = execution_pauses[i]; | 500 var pause = execution_pauses[i]; |
| 498 print(pause.end + " " + pause.duration()); | 501 print(pause.end + " " + pause.duration()); |
| 499 } | 502 } |
| 500 print("e"); | 503 print("e"); |
| 501 } | 504 } |
| 502 | 505 |
| 503 | 506 |
| 507 ParseArguments(arguments); |
| 504 CollectData(); | 508 CollectData(); |
| 509 FindPlotRange(); |
| 505 GnuplotOutput(); | 510 GnuplotOutput(); |
| OLD | NEW |