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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 | 434 |
435 | 435 |
436 TickProcessor.prototype.printStatistics = function() { | 436 TickProcessor.prototype.printStatistics = function() { |
437 print('Statistical profiling result from ' + this.lastLogFileName_ + | 437 print('Statistical profiling result from ' + this.lastLogFileName_ + |
438 ', (' + this.ticks_.total + | 438 ', (' + this.ticks_.total + |
439 ' ticks, ' + this.ticks_.unaccounted + ' unaccounted, ' + | 439 ' ticks, ' + this.ticks_.unaccounted + ' unaccounted, ' + |
440 this.ticks_.excluded + ' excluded).'); | 440 this.ticks_.excluded + ' excluded).'); |
441 | 441 |
442 if (this.ticks_.total == 0) return; | 442 if (this.ticks_.total == 0) return; |
443 | 443 |
444 // Print the unknown ticks percentage if they are not ignored. | |
445 if (!this.ignoreUnknown_ && this.ticks_.unaccounted > 0) { | |
446 this.printHeader('Unknown'); | |
447 this.printCounter(this.ticks_.unaccounted, this.ticks_.total); | |
448 } | |
449 | |
450 var flatProfile = this.profile_.getFlatProfile(); | 444 var flatProfile = this.profile_.getFlatProfile(); |
451 var flatView = this.viewBuilder_.buildView(flatProfile); | 445 var flatView = this.viewBuilder_.buildView(flatProfile); |
452 // Sort by self time, desc, then by name, desc. | 446 // Sort by self time, desc, then by name, desc. |
453 flatView.sort(function(rec1, rec2) { | 447 flatView.sort(function(rec1, rec2) { |
454 return rec2.selfTime - rec1.selfTime || | 448 return rec2.selfTime - rec1.selfTime || |
455 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); | 449 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); |
456 var totalTicks = this.ticks_.total; | 450 var totalTicks = this.ticks_.total; |
457 if (this.ignoreUnknown_) { | 451 if (this.ignoreUnknown_) { |
458 totalTicks -= this.ticks_.unaccounted; | 452 totalTicks -= this.ticks_.unaccounted; |
459 } | 453 } |
460 // Our total time contains all the ticks encountered, | |
461 // while profile only knows about the filtered ticks. | |
462 flatView.head.totalTime = totalTicks; | |
463 | 454 |
464 // Count library ticks | 455 // Count library ticks |
465 var flatViewNodes = flatView.head.children; | 456 var flatViewNodes = flatView.head.children; |
466 var self = this; | 457 var self = this; |
| 458 |
467 var libraryTicks = 0; | 459 var libraryTicks = 0; |
468 this.processProfile(flatViewNodes, | 460 this.printHeader('Shared libraries'); |
| 461 this.printEntries(flatViewNodes, totalTicks, null, |
469 function(name) { return self.isSharedLibrary(name); }, | 462 function(name) { return self.isSharedLibrary(name); }, |
470 function(rec) { libraryTicks += rec.selfTime; }); | 463 function(rec) { libraryTicks += rec.selfTime; }); |
471 var nonLibraryTicks = totalTicks - libraryTicks; | 464 var nonLibraryTicks = totalTicks - libraryTicks; |
472 | 465 |
473 this.printHeader('Shared libraries'); | 466 var jsTicks = 0; |
474 this.printEntries(flatViewNodes, null, | 467 this.printHeader('JavaScript'); |
475 function(name) { return self.isSharedLibrary(name); }); | 468 this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks, |
| 469 function(name) { return self.isJsCode(name); }, |
| 470 function(rec) { jsTicks += rec.selfTime; }); |
476 | 471 |
477 this.printHeader('JavaScript'); | 472 var cppTicks = 0; |
478 this.printEntries(flatViewNodes, nonLibraryTicks, | 473 this.printHeader('C++'); |
479 function(name) { return self.isJsCode(name); }); | 474 this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks, |
| 475 function(name) { return self.isCppCode(name); }, |
| 476 function(rec) { cppTicks += rec.selfTime; }); |
480 | 477 |
481 this.printHeader('C++'); | 478 this.printHeader('Summary'); |
482 this.printEntries(flatViewNodes, nonLibraryTicks, | 479 this.printLine('JavaScript', jsTicks, totalTicks, nonLibraryTicks); |
483 function(name) { return self.isCppCode(name); }); | 480 this.printLine('C++', cppTicks, totalTicks, nonLibraryTicks); |
484 | 481 this.printLine('GC', this.ticks_.gc, totalTicks, nonLibraryTicks); |
485 this.printHeader('GC'); | 482 this.printLine('Shared libraries', libraryTicks, totalTicks, null); |
486 this.printCounter(this.ticks_.gc, totalTicks); | 483 if (!this.ignoreUnknown_ && this.ticks_.unaccounted > 0) { |
| 484 this.printLine('Unaccounted', this.ticks_.unaccounted, |
| 485 this.ticks_.total, null); |
| 486 } |
487 | 487 |
488 this.printHeavyProfHeader(); | 488 this.printHeavyProfHeader(); |
489 var heavyProfile = this.profile_.getBottomUpProfile(); | 489 var heavyProfile = this.profile_.getBottomUpProfile(); |
490 var heavyView = this.viewBuilder_.buildView(heavyProfile); | 490 var heavyView = this.viewBuilder_.buildView(heavyProfile); |
491 // To show the same percentages as in the flat profile. | 491 // To show the same percentages as in the flat profile. |
492 heavyView.head.totalTime = totalTicks; | 492 heavyView.head.totalTime = totalTicks; |
493 // Sort by total time, desc, then by name, desc. | 493 // Sort by total time, desc, then by name, desc. |
494 heavyView.sort(function(rec1, rec2) { | 494 heavyView.sort(function(rec1, rec2) { |
495 return rec2.totalTime - rec1.totalTime || | 495 return rec2.totalTime - rec1.totalTime || |
496 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); | 496 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); |
(...skipping 13 matching lines...) Expand all Loading... |
510 return s; | 510 return s; |
511 }; | 511 }; |
512 | 512 |
513 | 513 |
514 TickProcessor.prototype.printHeader = function(headerTitle) { | 514 TickProcessor.prototype.printHeader = function(headerTitle) { |
515 print('\n [' + headerTitle + ']:'); | 515 print('\n [' + headerTitle + ']:'); |
516 print(' ticks total nonlib name'); | 516 print(' ticks total nonlib name'); |
517 }; | 517 }; |
518 | 518 |
519 | 519 |
| 520 TickProcessor.prototype.printLine = function( |
| 521 entry, ticks, totalTicks, nonLibTicks) { |
| 522 var pct = ticks * 100 / totalTicks; |
| 523 var nonLibPct = nonLibTicks != null |
| 524 ? padLeft((ticks * 100 / nonLibTicks).toFixed(1), 5) + '% ' |
| 525 : ' '; |
| 526 print(' ' + padLeft(ticks, 5) + ' ' + |
| 527 padLeft(pct.toFixed(1), 5) + '% ' + |
| 528 nonLibPct + |
| 529 entry); |
| 530 } |
| 531 |
520 TickProcessor.prototype.printHeavyProfHeader = function() { | 532 TickProcessor.prototype.printHeavyProfHeader = function() { |
521 print('\n [Bottom up (heavy) profile]:'); | 533 print('\n [Bottom up (heavy) profile]:'); |
522 print(' Note: percentage shows a share of a particular caller in the ' + | 534 print(' Note: percentage shows a share of a particular caller in the ' + |
523 'total\n' + | 535 'total\n' + |
524 ' amount of its parent calls.'); | 536 ' amount of its parent calls.'); |
525 print(' Callers occupying less than ' + | 537 print(' Callers occupying less than ' + |
526 TickProcessor.CALL_PROFILE_CUTOFF_PCT.toFixed(1) + | 538 TickProcessor.CALL_PROFILE_CUTOFF_PCT.toFixed(1) + |
527 '% are not shown.\n'); | 539 '% are not shown.\n'); |
528 print(' ticks parent name'); | 540 print(' ticks parent name'); |
529 }; | 541 }; |
530 | 542 |
531 | 543 |
532 TickProcessor.prototype.printCounter = function(ticksCount, totalTicksCount) { | |
533 var pct = ticksCount * 100.0 / totalTicksCount; | |
534 print(' ' + padLeft(ticksCount, 5) + ' ' + padLeft(pct.toFixed(1), 5) + '%')
; | |
535 }; | |
536 | |
537 | |
538 TickProcessor.prototype.processProfile = function( | 544 TickProcessor.prototype.processProfile = function( |
539 profile, filterP, func) { | 545 profile, filterP, func) { |
540 for (var i = 0, n = profile.length; i < n; ++i) { | 546 for (var i = 0, n = profile.length; i < n; ++i) { |
541 var rec = profile[i]; | 547 var rec = profile[i]; |
542 if (!filterP(rec.internalFuncName)) { | 548 if (!filterP(rec.internalFuncName)) { |
543 continue; | 549 continue; |
544 } | 550 } |
545 func(rec); | 551 func(rec); |
546 } | 552 } |
547 }; | 553 }; |
(...skipping 25 matching lines...) Expand all Loading... |
573 var column = lc.column - 1; | 579 var column = lc.column - 1; |
574 var entry = this.sourceMap.findEntry(lineNumber, column); | 580 var entry = this.sourceMap.findEntry(lineNumber, column); |
575 var sourceFile = entry[2]; | 581 var sourceFile = entry[2]; |
576 var sourceLine = entry[3] + 1; | 582 var sourceLine = entry[3] + 1; |
577 var sourceColumn = entry[4] + 1; | 583 var sourceColumn = entry[4] + 1; |
578 | 584 |
579 return sourceFile + ':' + sourceLine + ':' + sourceColumn + ' -> ' + funcName; | 585 return sourceFile + ':' + sourceLine + ':' + sourceColumn + ' -> ' + funcName; |
580 }; | 586 }; |
581 | 587 |
582 TickProcessor.prototype.printEntries = function( | 588 TickProcessor.prototype.printEntries = function( |
583 profile, nonLibTicks, filterP) { | 589 profile, totalTicks, nonLibTicks, filterP, callback) { |
584 var that = this; | 590 var that = this; |
585 this.processProfile(profile, filterP, function (rec) { | 591 this.processProfile(profile, filterP, function (rec) { |
586 if (rec.selfTime == 0) return; | 592 if (rec.selfTime == 0) return; |
587 var nonLibPct = nonLibTicks != null ? | 593 callback(rec); |
588 rec.selfTime * 100.0 / nonLibTicks : 0.0; | |
589 var funcName = that.formatFunctionName(rec.internalFuncName); | 594 var funcName = that.formatFunctionName(rec.internalFuncName); |
590 | 595 that.printLine(funcName, rec.selfTime, totalTicks, nonLibTicks); |
591 print(' ' + padLeft(rec.selfTime, 5) + ' ' + | |
592 padLeft(rec.selfPercent.toFixed(1), 5) + '% ' + | |
593 padLeft(nonLibPct.toFixed(1), 5) + '% ' + | |
594 funcName); | |
595 }); | 596 }); |
596 }; | 597 }; |
597 | 598 |
598 | 599 |
599 TickProcessor.prototype.printHeavyProfile = function(profile, opt_indent) { | 600 TickProcessor.prototype.printHeavyProfile = function(profile, opt_indent) { |
600 var self = this; | 601 var self = this; |
601 var indent = opt_indent || 0; | 602 var indent = opt_indent || 0; |
602 var indentStr = padLeft('', indent); | 603 var indentStr = padLeft('', indent); |
603 this.processProfile(profile, function() { return true; }, function (rec) { | 604 this.processProfile(profile, function() { return true; }, function (rec) { |
604 // Cut off too infrequent callers. | 605 // Cut off too infrequent callers. |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 for (var synArg in this.argsDispatch_) { | 944 for (var synArg in this.argsDispatch_) { |
944 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { | 945 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { |
945 synonims.push(synArg); | 946 synonims.push(synArg); |
946 delete this.argsDispatch_[synArg]; | 947 delete this.argsDispatch_[synArg]; |
947 } | 948 } |
948 } | 949 } |
949 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); | 950 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); |
950 } | 951 } |
951 quit(2); | 952 quit(2); |
952 }; | 953 }; |
OLD | NEW |