Index: tools/tickprocessor.js |
diff --git a/tools/tickprocessor.js b/tools/tickprocessor.js |
index d8575738553aa93f46116489312232d31acf8cf5..6eadb768305cde3ad0032f1c40ac54f3d92ce893 100644 |
--- a/tools/tickprocessor.js |
+++ b/tools/tickprocessor.js |
@@ -156,7 +156,8 @@ function TickProcessor( |
range, |
sourceMap, |
timedRange, |
- pairwiseTimedRange) { |
+ pairwiseTimedRange, |
+ printSummary) { |
LogReader.call(this, { |
'shared-library': { parsers: [null, parseInt, parseInt], |
processor: this.processSharedLibrary }, |
@@ -247,6 +248,7 @@ function TickProcessor( |
this.generation_ = 1; |
this.currentProducerProfile_ = null; |
+ this.printSummary_ = printSummary; |
}; |
inherits(TickProcessor, LogReader); |
@@ -456,29 +458,31 @@ TickProcessor.prototype.printStatistics = function() { |
if (this.ignoreUnknown_) { |
totalTicks -= this.ticks_.unaccounted; |
} |
+ 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.
|
+ this.printSummary_ == false; |
// Count library ticks |
var flatViewNodes = flatView.head.children; |
var self = this; |
var libraryTicks = 0; |
- this.printHeader('Shared libraries'); |
+ if(printAllTicks) this.printHeader('Shared libraries'); |
this.printEntries(flatViewNodes, totalTicks, null, |
function(name) { return self.isSharedLibrary(name); }, |
- function(rec) { libraryTicks += rec.selfTime; }); |
+ function(rec) { libraryTicks += rec.selfTime; }, printAllTicks); |
var nonLibraryTicks = totalTicks - libraryTicks; |
var jsTicks = 0; |
- this.printHeader('JavaScript'); |
+ if(printAllTicks) this.printHeader('JavaScript'); |
this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks, |
function(name) { return self.isJsCode(name); }, |
- function(rec) { jsTicks += rec.selfTime; }); |
+ function(rec) { jsTicks += rec.selfTime; }, printAllTicks); |
var cppTicks = 0; |
- this.printHeader('C++'); |
+ if(printAllTicks) this.printHeader('C++'); |
this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks, |
function(name) { return self.isCppCode(name); }, |
- function(rec) { cppTicks += rec.selfTime; }); |
+ function(rec) { cppTicks += rec.selfTime; }, printAllTicks); |
this.printHeader('Summary'); |
this.printLine('JavaScript', jsTicks, totalTicks, nonLibraryTicks); |
@@ -490,26 +494,28 @@ TickProcessor.prototype.printStatistics = function() { |
this.ticks_.total, null); |
} |
- print('\n [C++ entry points]:'); |
- print(' ticks cpp total name'); |
- var c_entry_functions = this.profile_.getCEntryProfile(); |
- var total_c_entry = c_entry_functions[0].ticks; |
- for (var i = 1; i < c_entry_functions.length; i++) { |
- c = c_entry_functions[i]; |
- this.printLine(c.name, c.ticks, total_c_entry, totalTicks); |
- } |
+ if(printAllTicks) { |
+ print('\n [C++ entry points]:'); |
+ print(' ticks cpp total name'); |
+ var c_entry_functions = this.profile_.getCEntryProfile(); |
+ var total_c_entry = c_entry_functions[0].ticks; |
+ for (var i = 1; i < c_entry_functions.length; i++) { |
+ c = c_entry_functions[i]; |
+ this.printLine(c.name, c.ticks, total_c_entry, totalTicks); |
+ } |
- this.printHeavyProfHeader(); |
- var heavyProfile = this.profile_.getBottomUpProfile(); |
- var heavyView = this.viewBuilder_.buildView(heavyProfile); |
- // To show the same percentages as in the flat profile. |
- heavyView.head.totalTime = totalTicks; |
- // Sort by total time, desc, then by name, desc. |
- heavyView.sort(function(rec1, rec2) { |
- return rec2.totalTime - rec1.totalTime || |
- (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); |
- this.printHeavyProfile(heavyView.head.children); |
-}; |
+ this.printHeavyProfHeader(); |
+ var heavyProfile = this.profile_.getBottomUpProfile(); |
+ var heavyView = this.viewBuilder_.buildView(heavyProfile); |
+ // To show the same percentages as in the flat profile. |
+ heavyView.head.totalTime = totalTicks; |
+ // Sort by total time, desc, then by name, desc. |
+ heavyView.sort(function(rec1, rec2) { |
+ return rec2.totalTime - rec1.totalTime || |
+ (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); |
+ this.printHeavyProfile(heavyView.head.children); |
+ } |
Michael Achenbach
2015/09/03 08:19:11
nit: indentation of } and };
gdeepti1
2015/09/03 17:50:21
Done.
|
+ }; |
function padLeft(s, len) { |
@@ -600,13 +606,15 @@ TickProcessor.prototype.formatFunctionName = function(funcName) { |
}; |
TickProcessor.prototype.printEntries = function( |
- profile, totalTicks, nonLibTicks, filterP, callback) { |
+ profile, totalTicks, nonLibTicks, filterP, callback, printAllTicks) { |
var that = this; |
this.processProfile(profile, filterP, function (rec) { |
if (rec.selfTime == 0) return; |
callback(rec); |
var funcName = that.formatFunctionName(rec.internalFuncName); |
- that.printLine(funcName, rec.selfTime, totalTicks, nonLibTicks); |
+ if(printAllTicks) { |
+ that.printLine(funcName, rec.selfTime, totalTicks, nonLibTicks); |
+ } |
}); |
}; |
@@ -884,7 +892,9 @@ function ArgumentsProcessor(args) { |
'--timed-range': ['timedRange', true, |
'Ignore ticks before first and after last Date.now() call'], |
'--pairwise-timed-range': ['pairwiseTimedRange', true, |
- 'Ignore ticks outside pairs of Date.now() calls'] |
+ 'Ignore ticks outside pairs of Date.now() calls'], |
+ '--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.
|
+ 'Print only tick summary, exclude other information'] |
}; |
this.argsDispatch_['--js'] = this.argsDispatch_['-j']; |
this.argsDispatch_['--gc'] = this.argsDispatch_['-g']; |
@@ -908,7 +918,8 @@ ArgumentsProcessor.DEFAULTS = { |
range: 'auto,auto', |
distortion: 0, |
timedRange: false, |
- pairwiseTimedRange: false |
+ pairwiseTimedRange: false, |
+ printSummary: false |
}; |