Tick processor: improved [Summary] section
R=yangguo@chromium.org Review URL: https://codereview.chromium.org/433043003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22801 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
35f0976895
commit
f66ddb1845
@ -168,24 +168,6 @@ ProfileView.Node = function(
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns a share of the function's total time in application's total time.
|
||||
*/
|
||||
ProfileView.Node.prototype.__defineGetter__(
|
||||
'totalPercent',
|
||||
function() { return this.totalTime /
|
||||
(this.head ? this.head.totalTime : this.totalTime) * 100.0; });
|
||||
|
||||
|
||||
/**
|
||||
* Returns a share of the function's self time in application's total time.
|
||||
*/
|
||||
ProfileView.Node.prototype.__defineGetter__(
|
||||
'selfPercent',
|
||||
function() { return this.selfTime /
|
||||
(this.head ? this.head.totalTime : this.totalTime) * 100.0; });
|
||||
|
||||
|
||||
/**
|
||||
* Returns a share of the function's total time in its parent's total time.
|
||||
*/
|
||||
|
@ -441,12 +441,6 @@ TickProcessor.prototype.printStatistics = function() {
|
||||
|
||||
if (this.ticks_.total == 0) return;
|
||||
|
||||
// Print the unknown ticks percentage if they are not ignored.
|
||||
if (!this.ignoreUnknown_ && this.ticks_.unaccounted > 0) {
|
||||
this.printHeader('Unknown');
|
||||
this.printCounter(this.ticks_.unaccounted, this.ticks_.total);
|
||||
}
|
||||
|
||||
var flatProfile = this.profile_.getFlatProfile();
|
||||
var flatView = this.viewBuilder_.buildView(flatProfile);
|
||||
// Sort by self time, desc, then by name, desc.
|
||||
@ -457,33 +451,39 @@ TickProcessor.prototype.printStatistics = function() {
|
||||
if (this.ignoreUnknown_) {
|
||||
totalTicks -= this.ticks_.unaccounted;
|
||||
}
|
||||
// Our total time contains all the ticks encountered,
|
||||
// while profile only knows about the filtered ticks.
|
||||
flatView.head.totalTime = totalTicks;
|
||||
|
||||
// Count library ticks
|
||||
var flatViewNodes = flatView.head.children;
|
||||
var self = this;
|
||||
|
||||
var libraryTicks = 0;
|
||||
this.processProfile(flatViewNodes,
|
||||
this.printHeader('Shared libraries');
|
||||
this.printEntries(flatViewNodes, totalTicks, null,
|
||||
function(name) { return self.isSharedLibrary(name); },
|
||||
function(rec) { libraryTicks += rec.selfTime; });
|
||||
var nonLibraryTicks = totalTicks - libraryTicks;
|
||||
|
||||
this.printHeader('Shared libraries');
|
||||
this.printEntries(flatViewNodes, null,
|
||||
function(name) { return self.isSharedLibrary(name); });
|
||||
|
||||
var jsTicks = 0;
|
||||
this.printHeader('JavaScript');
|
||||
this.printEntries(flatViewNodes, nonLibraryTicks,
|
||||
function(name) { return self.isJsCode(name); });
|
||||
this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks,
|
||||
function(name) { return self.isJsCode(name); },
|
||||
function(rec) { jsTicks += rec.selfTime; });
|
||||
|
||||
var cppTicks = 0;
|
||||
this.printHeader('C++');
|
||||
this.printEntries(flatViewNodes, nonLibraryTicks,
|
||||
function(name) { return self.isCppCode(name); });
|
||||
this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks,
|
||||
function(name) { return self.isCppCode(name); },
|
||||
function(rec) { cppTicks += rec.selfTime; });
|
||||
|
||||
this.printHeader('GC');
|
||||
this.printCounter(this.ticks_.gc, totalTicks);
|
||||
this.printHeader('Summary');
|
||||
this.printLine('JavaScript', jsTicks, totalTicks, nonLibraryTicks);
|
||||
this.printLine('C++', cppTicks, totalTicks, nonLibraryTicks);
|
||||
this.printLine('GC', this.ticks_.gc, totalTicks, nonLibraryTicks);
|
||||
this.printLine('Shared libraries', libraryTicks, totalTicks, null);
|
||||
if (!this.ignoreUnknown_ && this.ticks_.unaccounted > 0) {
|
||||
this.printLine('Unaccounted', this.ticks_.unaccounted,
|
||||
this.ticks_.total, null);
|
||||
}
|
||||
|
||||
this.printHeavyProfHeader();
|
||||
var heavyProfile = this.profile_.getBottomUpProfile();
|
||||
@ -517,6 +517,18 @@ TickProcessor.prototype.printHeader = function(headerTitle) {
|
||||
};
|
||||
|
||||
|
||||
TickProcessor.prototype.printLine = function(
|
||||
entry, ticks, totalTicks, nonLibTicks) {
|
||||
var pct = ticks * 100 / totalTicks;
|
||||
var nonLibPct = nonLibTicks != null
|
||||
? padLeft((ticks * 100 / nonLibTicks).toFixed(1), 5) + '% '
|
||||
: ' ';
|
||||
print(' ' + padLeft(ticks, 5) + ' ' +
|
||||
padLeft(pct.toFixed(1), 5) + '% ' +
|
||||
nonLibPct +
|
||||
entry);
|
||||
}
|
||||
|
||||
TickProcessor.prototype.printHeavyProfHeader = function() {
|
||||
print('\n [Bottom up (heavy) profile]:');
|
||||
print(' Note: percentage shows a share of a particular caller in the ' +
|
||||
@ -529,12 +541,6 @@ TickProcessor.prototype.printHeavyProfHeader = function() {
|
||||
};
|
||||
|
||||
|
||||
TickProcessor.prototype.printCounter = function(ticksCount, totalTicksCount) {
|
||||
var pct = ticksCount * 100.0 / totalTicksCount;
|
||||
print(' ' + padLeft(ticksCount, 5) + ' ' + padLeft(pct.toFixed(1), 5) + '%');
|
||||
};
|
||||
|
||||
|
||||
TickProcessor.prototype.processProfile = function(
|
||||
profile, filterP, func) {
|
||||
for (var i = 0, n = profile.length; i < n; ++i) {
|
||||
@ -580,18 +586,13 @@ TickProcessor.prototype.formatFunctionName = function(funcName) {
|
||||
};
|
||||
|
||||
TickProcessor.prototype.printEntries = function(
|
||||
profile, nonLibTicks, filterP) {
|
||||
profile, totalTicks, nonLibTicks, filterP, callback) {
|
||||
var that = this;
|
||||
this.processProfile(profile, filterP, function (rec) {
|
||||
if (rec.selfTime == 0) return;
|
||||
var nonLibPct = nonLibTicks != null ?
|
||||
rec.selfTime * 100.0 / nonLibTicks : 0.0;
|
||||
callback(rec);
|
||||
var funcName = that.formatFunctionName(rec.internalFuncName);
|
||||
|
||||
print(' ' + padLeft(rec.selfTime, 5) + ' ' +
|
||||
padLeft(rec.selfPercent.toFixed(1), 5) + '% ' +
|
||||
padLeft(nonLibPct.toFixed(1), 5) + '% ' +
|
||||
funcName);
|
||||
that.printLine(funcName, rec.selfTime, totalTicks, nonLibTicks);
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user