Chromium Code Reviews| Index: tools/tickprocessor.js |
| =================================================================== |
| --- tools/tickprocessor.js (revision 16936) |
| +++ tools/tickprocessor.js (working copy) |
| @@ -44,6 +44,13 @@ |
| /^(?:CallIC|LoadIC|StoreIC)|(?:Builtin: (?:Keyed)?(?:Call|Load|Store)IC_)/; |
| +function ProfileMark(name, ticks, codeGenerated) { |
| + this.name = name; |
| + this.ticks = ticks; |
| + this.codeGenerated = codeGenerated; |
| +} |
| + |
| + |
| /** |
| * A thin wrapper around shell's 'read' function showing a file name on error. |
| */ |
| @@ -181,6 +188,7 @@ |
| processor: this.advanceDistortion }, |
| 'timer-event-end' : { parsers: [null, null, null], |
| processor: this.advanceDistortion }, |
| + 'mark' : { parsers: [null], processor: this.processMark }, |
| // Ignored events. |
| 'profiler': null, |
| 'function-creation': null, |
| @@ -200,7 +208,8 @@ |
| this.sourceMap = sourceMap; |
| this.deserializedEntriesNames_ = []; |
| var ticks = this.ticks_ = |
| - { total: 0, unaccounted: 0, excluded: 0, gc: 0 }; |
| + { total: 0, unaccounted: 0, excluded: 0, states: [0, 0, 0, 0, 0, 0]}; |
| + this.codeGenerated_ = 0; |
| distortion = parseInt(distortion); |
| // Convert picoseconds to nanoseconds. |
| @@ -242,17 +251,21 @@ |
| this.generation_ = 1; |
| this.currentProducerProfile_ = null; |
| + |
| + this.marks_ = []; |
| }; |
| inherits(TickProcessor, LogReader); |
| TickProcessor.VmStates = { |
| + FIRST: 0, |
| JS: 0, |
| GC: 1, |
| COMPILER: 2, |
| OTHER: 3, |
| EXTERNAL: 4, |
| - IDLE: 5 |
| + IDLE: 5, |
| + COUNT: 6 |
| }; |
| @@ -302,6 +315,10 @@ |
| while (line = readline()) { |
| this.processLogLine(line); |
| } |
| + // If marks are present add a final marker. |
| + if (this.marks_.length > 0) { |
| + this.processMark("<end of log file>"); |
| + } |
| }; |
| @@ -329,6 +346,7 @@ |
| TickProcessor.prototype.processCodeCreation = function( |
| type, kind, start, size, name, maybe_func) { |
| + this.codeGenerated_ += size; |
| name = this.deserializedEntriesNames_[start] || name; |
| if (maybe_func.length) { |
| var funcAddr = parseInt(maybe_func[0]); |
| @@ -379,7 +397,7 @@ |
| return; |
| } |
| this.ticks_.total++; |
| - if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++; |
| + this.ticks_.states[vmState]++; |
| if (!this.includeTick(vmState)) { |
| this.ticks_.excluded++; |
| return; |
| @@ -404,6 +422,12 @@ |
| }; |
| +TickProcessor.prototype.processMark = function(name) { |
| + this.marks_.push( |
| + new ProfileMark(name, this.ticks_.total, this.codeGenerated_)); |
| +} |
| + |
| + |
| TickProcessor.prototype.advanceDistortion = function() { |
| this.distortion += this.distortion_per_entry; |
| } |
| @@ -482,9 +506,25 @@ |
| this.printEntries(flatViewNodes, nonLibraryTicks, |
| function(name) { return self.isCppCode(name); }); |
| - this.printHeader('GC'); |
| - this.printCounter(this.ticks_.gc, totalTicks); |
| + this.printTicksListHeader('States', 20); |
| + var vmStateNames = [ |
| + "JavaScript", |
| + "GC", |
| + "Compiler", |
| + "Other", |
| + "External", |
| + "Idle" |
| + ]; |
| + for (var state = TickProcessor.VmStates.FIRST; |
| + state < TickProcessor.VmStates.COUNT; |
| + state++) { |
| + if (this.stateFilter_ == null || this.stateFilter_ == state) { |
| + this.printLabledCounter( |
| + vmStateNames[state], this.ticks_.states[state], totalTicks); |
| + } |
| + } |
| + |
| this.printHeavyProfHeader(); |
| var heavyProfile = this.profile_.getBottomUpProfile(); |
| var heavyView = this.viewBuilder_.buildView(heavyProfile); |
| @@ -495,6 +535,37 @@ |
| return rec2.totalTime - rec1.totalTime || |
| (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); |
| this.printHeavyProfile(heavyView.head.children); |
| + |
| + if (this.marks_.length > 0) { |
| + var maxLength = 0; |
| + this.marks_.forEach(function (mark) { |
| + maxLength = Math.max(maxLength, mark.name.length); |
| + }); |
| + print(' [Marks]'); |
| + print(' ' + padRight('Name', 20) + |
| + ' ' + padLeft('Ticks', 6) + |
|
Yang
2013/09/30 11:25:02
Please align those lines like the print below.
|
| + ' ' + padLeft('Delta', 6) + |
| + ' ' + padLeft('Code (kb)', 10) + |
| + ' ' + padLeft('Delta (kb)', 11)); |
| + var lastTicks = 0; |
| + var lastCodeGenerated = 0; |
| + this.marks_.forEach(function (mark) { |
| + var ticksDelta = mark.ticks - lastTicks; |
| + var codeGeneratedDelta = |
| + Math.round((mark.codeGenerated - lastCodeGenerated) / 1024); |
| + print(' ' + padRight(mark.name, 20) + |
| + ' ' + padLeft(mark.ticks, 6) + |
| + ' ' + padLeft(ticksDelta, 6) + |
| + ' ' + padLeft(Math.round(mark.codeGenerated / 1024), 10) + |
| + ' ' + padLeft(codeGeneratedDelta, 11)); |
| + lastTicks = mark.ticks; |
| + lastCodeGenerated = mark.codeGenerated; |
| + }); |
| + } |
| + |
| + print(' [Code statistics]'); |
| + var generatedCode = Math.round(this.profile_.generatedCode / 1024); |
| + print(' Generated code: ' + generatedCode + ' kb'); |
| }; |
| @@ -511,12 +582,27 @@ |
| }; |
| +function padRight(s, len) { |
| + s = s.toString(); |
| + if (s.length < len) { |
| + s = s + (new Array(len - s.length + 1).join(' ')); |
| + } |
| + return s; |
| +} |
| + |
| + |
| TickProcessor.prototype.printHeader = function(headerTitle) { |
| print('\n [' + headerTitle + ']:'); |
| print(' ticks total nonlib name'); |
| }; |
| +TickProcessor.prototype.printTicksListHeader = function(headerTitle, padding) { |
| + print('\n [' + headerTitle + ']:'); |
| + print(' ' + padRight('category', padding) + ' ticks percentage'); |
| +}; |
| + |
| + |
| TickProcessor.prototype.printHeavyProfHeader = function() { |
| print('\n [Bottom up (heavy) profile]:'); |
| print(' Note: percentage shows a share of a particular caller in the ' + |
| @@ -535,6 +621,15 @@ |
| }; |
| +TickProcessor.prototype.printLabledCounter = function( |
| + label, ticksCount, totalTicksCount) { |
| + var pct = ticksCount * 100.0 / totalTicksCount; |
| + print(' ' + padRight(label, 20) + ' ' + |
| + padLeft(ticksCount, 5) + ' ' + |
| + padLeft(pct.toFixed(1), 10) + '%'); |
| +}; |
| + |
| + |
| TickProcessor.prototype.processProfile = function( |
| profile, filterP, func) { |
| for (var i = 0, n = profile.length; i < n; ++i) { |
| @@ -925,14 +1020,6 @@ |
| ArgumentsProcessor.prototype.printUsageAndExit = function() { |
| - function padRight(s, len) { |
| - s = s.toString(); |
| - if (s.length < len) { |
| - s = s + (new Array(len - s.length + 1).join(' ')); |
| - } |
| - return s; |
| - } |
| - |
| print('Cmdline args: [options] [log-file-name]\n' + |
| 'Default log file name is "' + |
| ArgumentsProcessor.DEFAULTS.logFileName + '".\n'); |
| @@ -950,4 +1037,3 @@ |
| } |
| quit(2); |
| }; |
| - |