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

Side by Side Diff: tools/tickprocessor.js

Issue 1318933004: [Tick processor] Add an option to the tick-processor to print the summary. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « test/mjsunit/tools/tickprocessor-test.print-summary ('k') | tools/tickprocessor-driver.js » ('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 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
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 printSummary) {
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
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.printSummary_ = printSummary;
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
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.printSummary_ == undefined ||
Jakob Kummerow 2015/09/03 08:37:08 How about simply: var printAllTicks = !this.onlyS
gdeepti1 2015/09/03 17:50:21 Done.
462 this.printSummary_ == false;
459 463
460 // Count library ticks 464 // Count library ticks
461 var flatViewNodes = flatView.head.children; 465 var flatViewNodes = flatView.head.children;
462 var self = this; 466 var self = this;
463 467
464 var libraryTicks = 0; 468 var libraryTicks = 0;
465 this.printHeader('Shared libraries'); 469 if(printAllTicks) this.printHeader('Shared libraries');
466 this.printEntries(flatViewNodes, totalTicks, null, 470 this.printEntries(flatViewNodes, totalTicks, null,
467 function(name) { return self.isSharedLibrary(name); }, 471 function(name) { return self.isSharedLibrary(name); },
468 function(rec) { libraryTicks += rec.selfTime; }); 472 function(rec) { libraryTicks += rec.selfTime; }, printAllTicks);
469 var nonLibraryTicks = totalTicks - libraryTicks; 473 var nonLibraryTicks = totalTicks - libraryTicks;
470 474
471 var jsTicks = 0; 475 var jsTicks = 0;
472 this.printHeader('JavaScript'); 476 if(printAllTicks) this.printHeader('JavaScript');
473 this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks, 477 this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks,
474 function(name) { return self.isJsCode(name); }, 478 function(name) { return self.isJsCode(name); },
475 function(rec) { jsTicks += rec.selfTime; }); 479 function(rec) { jsTicks += rec.selfTime; }, printAllTicks);
476 480
477 var cppTicks = 0; 481 var cppTicks = 0;
478 this.printHeader('C++'); 482 if(printAllTicks) this.printHeader('C++');
479 this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks, 483 this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks,
480 function(name) { return self.isCppCode(name); }, 484 function(name) { return self.isCppCode(name); },
481 function(rec) { cppTicks += rec.selfTime; }); 485 function(rec) { cppTicks += rec.selfTime; }, printAllTicks);
482 486
483 this.printHeader('Summary'); 487 this.printHeader('Summary');
484 this.printLine('JavaScript', jsTicks, totalTicks, nonLibraryTicks); 488 this.printLine('JavaScript', jsTicks, totalTicks, nonLibraryTicks);
485 this.printLine('C++', cppTicks, totalTicks, nonLibraryTicks); 489 this.printLine('C++', cppTicks, totalTicks, nonLibraryTicks);
486 this.printLine('GC', this.ticks_.gc, totalTicks, nonLibraryTicks); 490 this.printLine('GC', this.ticks_.gc, totalTicks, nonLibraryTicks);
487 this.printLine('Shared libraries', libraryTicks, totalTicks, null); 491 this.printLine('Shared libraries', libraryTicks, totalTicks, null);
488 if (!this.ignoreUnknown_ && this.ticks_.unaccounted > 0) { 492 if (!this.ignoreUnknown_ && this.ticks_.unaccounted > 0) {
489 this.printLine('Unaccounted', this.ticks_.unaccounted, 493 this.printLine('Unaccounted', this.ticks_.unaccounted,
490 this.ticks_.total, null); 494 this.ticks_.total, null);
491 } 495 }
492 496
493 print('\n [C++ entry points]:'); 497 if(printAllTicks) {
494 print(' ticks cpp total name'); 498 print('\n [C++ entry points]:');
495 var c_entry_functions = this.profile_.getCEntryProfile(); 499 print(' ticks cpp total name');
496 var total_c_entry = c_entry_functions[0].ticks; 500 var c_entry_functions = this.profile_.getCEntryProfile();
497 for (var i = 1; i < c_entry_functions.length; i++) { 501 var total_c_entry = c_entry_functions[0].ticks;
498 c = c_entry_functions[i]; 502 for (var i = 1; i < c_entry_functions.length; i++) {
499 this.printLine(c.name, c.ticks, total_c_entry, totalTicks); 503 c = c_entry_functions[i];
500 } 504 this.printLine(c.name, c.ticks, total_c_entry, totalTicks);
505 }
501 506
502 this.printHeavyProfHeader(); 507 this.printHeavyProfHeader();
503 var heavyProfile = this.profile_.getBottomUpProfile(); 508 var heavyProfile = this.profile_.getBottomUpProfile();
504 var heavyView = this.viewBuilder_.buildView(heavyProfile); 509 var heavyView = this.viewBuilder_.buildView(heavyProfile);
505 // To show the same percentages as in the flat profile. 510 // To show the same percentages as in the flat profile.
506 heavyView.head.totalTime = totalTicks; 511 heavyView.head.totalTime = totalTicks;
507 // Sort by total time, desc, then by name, desc. 512 // Sort by total time, desc, then by name, desc.
508 heavyView.sort(function(rec1, rec2) { 513 heavyView.sort(function(rec1, rec2) {
509 return rec2.totalTime - rec1.totalTime || 514 return rec2.totalTime - rec1.totalTime ||
510 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); 515 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); });
511 this.printHeavyProfile(heavyView.head.children); 516 this.printHeavyProfile(heavyView.head.children);
512 }; 517 }
Michael Achenbach 2015/09/03 08:19:11 nit: indentation of } and };
gdeepti1 2015/09/03 17:50:21 Done.
518 };
513 519
514 520
515 function padLeft(s, len) { 521 function padLeft(s, len) {
516 s = s.toString(); 522 s = s.toString();
517 if (s.length < len) { 523 if (s.length < len) {
518 var padLength = len - s.length; 524 var padLength = len - s.length;
519 if (!(padLength in padLeft)) { 525 if (!(padLength in padLeft)) {
520 padLeft[padLength] = new Array(padLength + 1).join(' '); 526 padLeft[padLength] = new Array(padLength + 1).join(' ');
521 } 527 }
522 s = padLeft[padLength] + s; 528 s = padLeft[padLength] + s;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 var column = lc.column - 1; 599 var column = lc.column - 1;
594 var entry = this.sourceMap.findEntry(lineNumber, column); 600 var entry = this.sourceMap.findEntry(lineNumber, column);
595 var sourceFile = entry[2]; 601 var sourceFile = entry[2];
596 var sourceLine = entry[3] + 1; 602 var sourceLine = entry[3] + 1;
597 var sourceColumn = entry[4] + 1; 603 var sourceColumn = entry[4] + 1;
598 604
599 return sourceFile + ':' + sourceLine + ':' + sourceColumn + ' -> ' + funcName; 605 return sourceFile + ':' + sourceLine + ':' + sourceColumn + ' -> ' + funcName;
600 }; 606 };
601 607
602 TickProcessor.prototype.printEntries = function( 608 TickProcessor.prototype.printEntries = function(
603 profile, totalTicks, nonLibTicks, filterP, callback) { 609 profile, totalTicks, nonLibTicks, filterP, callback, printAllTicks) {
604 var that = this; 610 var that = this;
605 this.processProfile(profile, filterP, function (rec) { 611 this.processProfile(profile, filterP, function (rec) {
606 if (rec.selfTime == 0) return; 612 if (rec.selfTime == 0) return;
607 callback(rec); 613 callback(rec);
608 var funcName = that.formatFunctionName(rec.internalFuncName); 614 var funcName = that.formatFunctionName(rec.internalFuncName);
609 that.printLine(funcName, rec.selfTime, totalTicks, nonLibTicks); 615 if(printAllTicks) {
616 that.printLine(funcName, rec.selfTime, totalTicks, nonLibTicks);
617 }
610 }); 618 });
611 }; 619 };
612 620
613 621
614 TickProcessor.prototype.printHeavyProfile = function(profile, opt_indent) { 622 TickProcessor.prototype.printHeavyProfile = function(profile, opt_indent) {
615 var self = this; 623 var self = this;
616 var indent = opt_indent || 0; 624 var indent = opt_indent || 0;
617 var indentStr = padLeft('', indent); 625 var indentStr = padLeft('', indent);
618 this.processProfile(profile, function() { return true; }, function (rec) { 626 this.processProfile(profile, function() { return true; }, function (rec) {
619 // Cut off too infrequent callers. 627 // Cut off too infrequent callers.
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)'], 885 'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)'],
878 '--range': ['range', 'auto,auto', 886 '--range': ['range', 'auto,auto',
879 'Specify the range limit as [start],[end]'], 887 'Specify the range limit as [start],[end]'],
880 '--distortion': ['distortion', 0, 888 '--distortion': ['distortion', 0,
881 'Specify the logging overhead in picoseconds'], 889 'Specify the logging overhead in picoseconds'],
882 '--source-map': ['sourceMap', null, 890 '--source-map': ['sourceMap', null,
883 'Specify the source map that should be used for output'], 891 'Specify the source map that should be used for output'],
884 '--timed-range': ['timedRange', true, 892 '--timed-range': ['timedRange', true,
885 'Ignore ticks before first and after last Date.now() call'], 893 'Ignore ticks before first and after last Date.now() call'],
886 '--pairwise-timed-range': ['pairwiseTimedRange', true, 894 '--pairwise-timed-range': ['pairwiseTimedRange', true,
887 'Ignore ticks outside pairs of Date.now() calls'] 895 'Ignore ticks outside pairs of Date.now() calls'],
896 '--print-summary': ['printSummary', true,
Jakob Kummerow 2015/09/03 08:37:08 I'd call the flag --only-summary (and the correspo
gdeepti1 2015/09/03 17:50:21 Done.
897 'Print only tick summary, exclude other information']
888 }; 898 };
889 this.argsDispatch_['--js'] = this.argsDispatch_['-j']; 899 this.argsDispatch_['--js'] = this.argsDispatch_['-j'];
890 this.argsDispatch_['--gc'] = this.argsDispatch_['-g']; 900 this.argsDispatch_['--gc'] = this.argsDispatch_['-g'];
891 this.argsDispatch_['--compiler'] = this.argsDispatch_['-c']; 901 this.argsDispatch_['--compiler'] = this.argsDispatch_['-c'];
892 this.argsDispatch_['--other'] = this.argsDispatch_['-o']; 902 this.argsDispatch_['--other'] = this.argsDispatch_['-o'];
893 this.argsDispatch_['--external'] = this.argsDispatch_['-e']; 903 this.argsDispatch_['--external'] = this.argsDispatch_['-e'];
894 this.argsDispatch_['--ptr'] = this.argsDispatch_['--pairwise-timed-range']; 904 this.argsDispatch_['--ptr'] = this.argsDispatch_['--pairwise-timed-range'];
895 }; 905 };
896 906
897 907
898 ArgumentsProcessor.DEFAULTS = { 908 ArgumentsProcessor.DEFAULTS = {
899 logFileName: 'v8.log', 909 logFileName: 'v8.log',
900 snapshotLogFileName: null, 910 snapshotLogFileName: null,
901 platform: 'unix', 911 platform: 'unix',
902 stateFilter: null, 912 stateFilter: null,
903 callGraphSize: 5, 913 callGraphSize: 5,
904 ignoreUnknown: false, 914 ignoreUnknown: false,
905 separateIc: false, 915 separateIc: false,
906 targetRootFS: '', 916 targetRootFS: '',
907 nm: 'nm', 917 nm: 'nm',
908 range: 'auto,auto', 918 range: 'auto,auto',
909 distortion: 0, 919 distortion: 0,
910 timedRange: false, 920 timedRange: false,
911 pairwiseTimedRange: false 921 pairwiseTimedRange: false,
922 printSummary: false
912 }; 923 };
913 924
914 925
915 ArgumentsProcessor.prototype.parse = function() { 926 ArgumentsProcessor.prototype.parse = function() {
916 while (this.args_.length) { 927 while (this.args_.length) {
917 var arg = this.args_.shift(); 928 var arg = this.args_.shift();
918 if (arg.charAt(0) != '-') { 929 if (arg.charAt(0) != '-') {
919 this.result_.logFileName = arg; 930 this.result_.logFileName = arg;
920 continue; 931 continue;
921 } 932 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 for (var synArg in this.argsDispatch_) { 972 for (var synArg in this.argsDispatch_) {
962 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { 973 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) {
963 synonyms.push(synArg); 974 synonyms.push(synArg);
964 delete this.argsDispatch_[synArg]; 975 delete this.argsDispatch_[synArg];
965 } 976 }
966 } 977 }
967 print(' ' + padRight(synonyms.join(', '), 20) + " " + dispatch[2]); 978 print(' ' + padRight(synonyms.join(', '), 20) + " " + dispatch[2]);
968 } 979 }
969 quit(2); 980 quit(2);
970 }; 981 };
OLDNEW
« no previous file with comments | « test/mjsunit/tools/tickprocessor-test.print-summary ('k') | tools/tickprocessor-driver.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698