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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 cppEntriesProvider, | 149 cppEntriesProvider, |
150 separateIc, | 150 separateIc, |
151 callGraphSize, | 151 callGraphSize, |
152 ignoreUnknown, | 152 ignoreUnknown, |
153 stateFilter, | 153 stateFilter, |
154 snapshotLogProcessor, | 154 snapshotLogProcessor, |
155 distortion, | 155 distortion, |
156 range, | 156 range, |
157 sourceMap, | 157 sourceMap, |
158 timedRange, | 158 timedRange, |
159 pairwiseTimedRange) { | 159 pairwiseTimedRange, |
| 160 onlySummary) { |
160 LogReader.call(this, { | 161 LogReader.call(this, { |
161 'shared-library': { parsers: [null, parseInt, parseInt], | 162 'shared-library': { parsers: [null, parseInt, parseInt], |
162 processor: this.processSharedLibrary }, | 163 processor: this.processSharedLibrary }, |
163 'code-creation': { | 164 'code-creation': { |
164 parsers: [null, parseInt, parseInt, parseInt, null, 'var-args'], | 165 parsers: [null, parseInt, parseInt, parseInt, null, 'var-args'], |
165 processor: this.processCodeCreation }, | 166 processor: this.processCodeCreation }, |
166 'code-move': { parsers: [parseInt, parseInt], | 167 'code-move': { parsers: [parseInt, parseInt], |
167 processor: this.processCodeMove }, | 168 processor: this.processCodeMove }, |
168 'code-delete': { parsers: [parseInt], | 169 'code-delete': { parsers: [parseInt], |
169 processor: this.processCodeDelete }, | 170 processor: this.processCodeDelete }, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 }; | 241 }; |
241 | 242 |
242 this.profile_ = new V8Profile(separateIc); | 243 this.profile_ = new V8Profile(separateIc); |
243 this.codeTypes_ = {}; | 244 this.codeTypes_ = {}; |
244 // Count each tick as a time unit. | 245 // Count each tick as a time unit. |
245 this.viewBuilder_ = new ViewBuilder(1); | 246 this.viewBuilder_ = new ViewBuilder(1); |
246 this.lastLogFileName_ = null; | 247 this.lastLogFileName_ = null; |
247 | 248 |
248 this.generation_ = 1; | 249 this.generation_ = 1; |
249 this.currentProducerProfile_ = null; | 250 this.currentProducerProfile_ = null; |
| 251 this.onlySummary_ = onlySummary; |
250 }; | 252 }; |
251 inherits(TickProcessor, LogReader); | 253 inherits(TickProcessor, LogReader); |
252 | 254 |
253 | 255 |
254 TickProcessor.VmStates = { | 256 TickProcessor.VmStates = { |
255 JS: 0, | 257 JS: 0, |
256 GC: 1, | 258 GC: 1, |
257 COMPILER: 2, | 259 COMPILER: 2, |
258 OTHER: 3, | 260 OTHER: 3, |
259 EXTERNAL: 4, | 261 EXTERNAL: 4, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 var flatProfile = this.profile_.getFlatProfile(); | 451 var flatProfile = this.profile_.getFlatProfile(); |
450 var flatView = this.viewBuilder_.buildView(flatProfile); | 452 var flatView = this.viewBuilder_.buildView(flatProfile); |
451 // Sort by self time, desc, then by name, desc. | 453 // Sort by self time, desc, then by name, desc. |
452 flatView.sort(function(rec1, rec2) { | 454 flatView.sort(function(rec1, rec2) { |
453 return rec2.selfTime - rec1.selfTime || | 455 return rec2.selfTime - rec1.selfTime || |
454 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); | 456 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); |
455 var totalTicks = this.ticks_.total; | 457 var totalTicks = this.ticks_.total; |
456 if (this.ignoreUnknown_) { | 458 if (this.ignoreUnknown_) { |
457 totalTicks -= this.ticks_.unaccounted; | 459 totalTicks -= this.ticks_.unaccounted; |
458 } | 460 } |
| 461 var printAllTicks = !this.onlySummary_; |
459 | 462 |
460 // Count library ticks | 463 // Count library ticks |
461 var flatViewNodes = flatView.head.children; | 464 var flatViewNodes = flatView.head.children; |
462 var self = this; | 465 var self = this; |
463 | 466 |
464 var libraryTicks = 0; | 467 var libraryTicks = 0; |
465 this.printHeader('Shared libraries'); | 468 if(printAllTicks) this.printHeader('Shared libraries'); |
466 this.printEntries(flatViewNodes, totalTicks, null, | 469 this.printEntries(flatViewNodes, totalTicks, null, |
467 function(name) { return self.isSharedLibrary(name); }, | 470 function(name) { return self.isSharedLibrary(name); }, |
468 function(rec) { libraryTicks += rec.selfTime; }); | 471 function(rec) { libraryTicks += rec.selfTime; }, printAllTicks); |
469 var nonLibraryTicks = totalTicks - libraryTicks; | 472 var nonLibraryTicks = totalTicks - libraryTicks; |
470 | 473 |
471 var jsTicks = 0; | 474 var jsTicks = 0; |
472 this.printHeader('JavaScript'); | 475 if(printAllTicks) this.printHeader('JavaScript'); |
473 this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks, | 476 this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks, |
474 function(name) { return self.isJsCode(name); }, | 477 function(name) { return self.isJsCode(name); }, |
475 function(rec) { jsTicks += rec.selfTime; }); | 478 function(rec) { jsTicks += rec.selfTime; }, printAllTicks); |
476 | 479 |
477 var cppTicks = 0; | 480 var cppTicks = 0; |
478 this.printHeader('C++'); | 481 if(printAllTicks) this.printHeader('C++'); |
479 this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks, | 482 this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks, |
480 function(name) { return self.isCppCode(name); }, | 483 function(name) { return self.isCppCode(name); }, |
481 function(rec) { cppTicks += rec.selfTime; }); | 484 function(rec) { cppTicks += rec.selfTime; }, printAllTicks); |
482 | 485 |
483 this.printHeader('Summary'); | 486 this.printHeader('Summary'); |
484 this.printLine('JavaScript', jsTicks, totalTicks, nonLibraryTicks); | 487 this.printLine('JavaScript', jsTicks, totalTicks, nonLibraryTicks); |
485 this.printLine('C++', cppTicks, totalTicks, nonLibraryTicks); | 488 this.printLine('C++', cppTicks, totalTicks, nonLibraryTicks); |
486 this.printLine('GC', this.ticks_.gc, totalTicks, nonLibraryTicks); | 489 this.printLine('GC', this.ticks_.gc, totalTicks, nonLibraryTicks); |
487 this.printLine('Shared libraries', libraryTicks, totalTicks, null); | 490 this.printLine('Shared libraries', libraryTicks, totalTicks, null); |
488 if (!this.ignoreUnknown_ && this.ticks_.unaccounted > 0) { | 491 if (!this.ignoreUnknown_ && this.ticks_.unaccounted > 0) { |
489 this.printLine('Unaccounted', this.ticks_.unaccounted, | 492 this.printLine('Unaccounted', this.ticks_.unaccounted, |
490 this.ticks_.total, null); | 493 this.ticks_.total, null); |
491 } | 494 } |
492 | 495 |
493 print('\n [C++ entry points]:'); | 496 if(printAllTicks) { |
494 print(' ticks cpp total name'); | 497 print('\n [C++ entry points]:'); |
495 var c_entry_functions = this.profile_.getCEntryProfile(); | 498 print(' ticks cpp total name'); |
496 var total_c_entry = c_entry_functions[0].ticks; | 499 var c_entry_functions = this.profile_.getCEntryProfile(); |
497 for (var i = 1; i < c_entry_functions.length; i++) { | 500 var total_c_entry = c_entry_functions[0].ticks; |
498 c = c_entry_functions[i]; | 501 for (var i = 1; i < c_entry_functions.length; i++) { |
499 this.printLine(c.name, c.ticks, total_c_entry, totalTicks); | 502 c = c_entry_functions[i]; |
| 503 this.printLine(c.name, c.ticks, total_c_entry, totalTicks); |
| 504 } |
| 505 |
| 506 this.printHeavyProfHeader(); |
| 507 var heavyProfile = this.profile_.getBottomUpProfile(); |
| 508 var heavyView = this.viewBuilder_.buildView(heavyProfile); |
| 509 // To show the same percentages as in the flat profile. |
| 510 heavyView.head.totalTime = totalTicks; |
| 511 // Sort by total time, desc, then by name, desc. |
| 512 heavyView.sort(function(rec1, rec2) { |
| 513 return rec2.totalTime - rec1.totalTime || |
| 514 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); |
| 515 this.printHeavyProfile(heavyView.head.children); |
500 } | 516 } |
501 | |
502 this.printHeavyProfHeader(); | |
503 var heavyProfile = this.profile_.getBottomUpProfile(); | |
504 var heavyView = this.viewBuilder_.buildView(heavyProfile); | |
505 // To show the same percentages as in the flat profile. | |
506 heavyView.head.totalTime = totalTicks; | |
507 // Sort by total time, desc, then by name, desc. | |
508 heavyView.sort(function(rec1, rec2) { | |
509 return rec2.totalTime - rec1.totalTime || | |
510 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); | |
511 this.printHeavyProfile(heavyView.head.children); | |
512 }; | 517 }; |
513 | 518 |
514 | 519 |
515 function padLeft(s, len) { | 520 function padLeft(s, len) { |
516 s = s.toString(); | 521 s = s.toString(); |
517 if (s.length < len) { | 522 if (s.length < len) { |
518 var padLength = len - s.length; | 523 var padLength = len - s.length; |
519 if (!(padLength in padLeft)) { | 524 if (!(padLength in padLeft)) { |
520 padLeft[padLength] = new Array(padLength + 1).join(' '); | 525 padLeft[padLength] = new Array(padLength + 1).join(' '); |
521 } | 526 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 var column = lc.column - 1; | 598 var column = lc.column - 1; |
594 var entry = this.sourceMap.findEntry(lineNumber, column); | 599 var entry = this.sourceMap.findEntry(lineNumber, column); |
595 var sourceFile = entry[2]; | 600 var sourceFile = entry[2]; |
596 var sourceLine = entry[3] + 1; | 601 var sourceLine = entry[3] + 1; |
597 var sourceColumn = entry[4] + 1; | 602 var sourceColumn = entry[4] + 1; |
598 | 603 |
599 return sourceFile + ':' + sourceLine + ':' + sourceColumn + ' -> ' + funcName; | 604 return sourceFile + ':' + sourceLine + ':' + sourceColumn + ' -> ' + funcName; |
600 }; | 605 }; |
601 | 606 |
602 TickProcessor.prototype.printEntries = function( | 607 TickProcessor.prototype.printEntries = function( |
603 profile, totalTicks, nonLibTicks, filterP, callback) { | 608 profile, totalTicks, nonLibTicks, filterP, callback, printAllTicks) { |
604 var that = this; | 609 var that = this; |
605 this.processProfile(profile, filterP, function (rec) { | 610 this.processProfile(profile, filterP, function (rec) { |
606 if (rec.selfTime == 0) return; | 611 if (rec.selfTime == 0) return; |
607 callback(rec); | 612 callback(rec); |
608 var funcName = that.formatFunctionName(rec.internalFuncName); | 613 var funcName = that.formatFunctionName(rec.internalFuncName); |
609 that.printLine(funcName, rec.selfTime, totalTicks, nonLibTicks); | 614 if(printAllTicks) { |
| 615 that.printLine(funcName, rec.selfTime, totalTicks, nonLibTicks); |
| 616 } |
610 }); | 617 }); |
611 }; | 618 }; |
612 | 619 |
613 | 620 |
614 TickProcessor.prototype.printHeavyProfile = function(profile, opt_indent) { | 621 TickProcessor.prototype.printHeavyProfile = function(profile, opt_indent) { |
615 var self = this; | 622 var self = this; |
616 var indent = opt_indent || 0; | 623 var indent = opt_indent || 0; |
617 var indentStr = padLeft('', indent); | 624 var indentStr = padLeft('', indent); |
618 this.processProfile(profile, function() { return true; }, function (rec) { | 625 this.processProfile(profile, function() { return true; }, function (rec) { |
619 // Cut off too infrequent callers. | 626 // Cut off too infrequent callers. |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)'], | 884 'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)'], |
878 '--range': ['range', 'auto,auto', | 885 '--range': ['range', 'auto,auto', |
879 'Specify the range limit as [start],[end]'], | 886 'Specify the range limit as [start],[end]'], |
880 '--distortion': ['distortion', 0, | 887 '--distortion': ['distortion', 0, |
881 'Specify the logging overhead in picoseconds'], | 888 'Specify the logging overhead in picoseconds'], |
882 '--source-map': ['sourceMap', null, | 889 '--source-map': ['sourceMap', null, |
883 'Specify the source map that should be used for output'], | 890 'Specify the source map that should be used for output'], |
884 '--timed-range': ['timedRange', true, | 891 '--timed-range': ['timedRange', true, |
885 'Ignore ticks before first and after last Date.now() call'], | 892 'Ignore ticks before first and after last Date.now() call'], |
886 '--pairwise-timed-range': ['pairwiseTimedRange', true, | 893 '--pairwise-timed-range': ['pairwiseTimedRange', true, |
887 'Ignore ticks outside pairs of Date.now() calls'] | 894 'Ignore ticks outside pairs of Date.now() calls'], |
| 895 '--only-summary': ['onlySummary', true, |
| 896 'Print only tick summary, exclude other information'] |
888 }; | 897 }; |
889 this.argsDispatch_['--js'] = this.argsDispatch_['-j']; | 898 this.argsDispatch_['--js'] = this.argsDispatch_['-j']; |
890 this.argsDispatch_['--gc'] = this.argsDispatch_['-g']; | 899 this.argsDispatch_['--gc'] = this.argsDispatch_['-g']; |
891 this.argsDispatch_['--compiler'] = this.argsDispatch_['-c']; | 900 this.argsDispatch_['--compiler'] = this.argsDispatch_['-c']; |
892 this.argsDispatch_['--other'] = this.argsDispatch_['-o']; | 901 this.argsDispatch_['--other'] = this.argsDispatch_['-o']; |
893 this.argsDispatch_['--external'] = this.argsDispatch_['-e']; | 902 this.argsDispatch_['--external'] = this.argsDispatch_['-e']; |
894 this.argsDispatch_['--ptr'] = this.argsDispatch_['--pairwise-timed-range']; | 903 this.argsDispatch_['--ptr'] = this.argsDispatch_['--pairwise-timed-range']; |
895 }; | 904 }; |
896 | 905 |
897 | 906 |
898 ArgumentsProcessor.DEFAULTS = { | 907 ArgumentsProcessor.DEFAULTS = { |
899 logFileName: 'v8.log', | 908 logFileName: 'v8.log', |
900 snapshotLogFileName: null, | 909 snapshotLogFileName: null, |
901 platform: 'unix', | 910 platform: 'unix', |
902 stateFilter: null, | 911 stateFilter: null, |
903 callGraphSize: 5, | 912 callGraphSize: 5, |
904 ignoreUnknown: false, | 913 ignoreUnknown: false, |
905 separateIc: false, | 914 separateIc: false, |
906 targetRootFS: '', | 915 targetRootFS: '', |
907 nm: 'nm', | 916 nm: 'nm', |
908 range: 'auto,auto', | 917 range: 'auto,auto', |
909 distortion: 0, | 918 distortion: 0, |
910 timedRange: false, | 919 timedRange: false, |
911 pairwiseTimedRange: false | 920 pairwiseTimedRange: false, |
| 921 onlySummary: false |
912 }; | 922 }; |
913 | 923 |
914 | 924 |
915 ArgumentsProcessor.prototype.parse = function() { | 925 ArgumentsProcessor.prototype.parse = function() { |
916 while (this.args_.length) { | 926 while (this.args_.length) { |
917 var arg = this.args_.shift(); | 927 var arg = this.args_.shift(); |
918 if (arg.charAt(0) != '-') { | 928 if (arg.charAt(0) != '-') { |
919 this.result_.logFileName = arg; | 929 this.result_.logFileName = arg; |
920 continue; | 930 continue; |
921 } | 931 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 for (var synArg in this.argsDispatch_) { | 971 for (var synArg in this.argsDispatch_) { |
962 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { | 972 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { |
963 synonyms.push(synArg); | 973 synonyms.push(synArg); |
964 delete this.argsDispatch_[synArg]; | 974 delete this.argsDispatch_[synArg]; |
965 } | 975 } |
966 } | 976 } |
967 print(' ' + padRight(synonyms.join(', '), 20) + " " + dispatch[2]); | 977 print(' ' + padRight(synonyms.join(', '), 20) + " " + dispatch[2]); |
968 } | 978 } |
969 quit(2); | 979 quit(2); |
970 }; | 980 }; |
OLD | NEW |