Make tickprocessor's ProfileView extensible and move out DevTools-only stuff.
Review URL: http://codereview.chromium.org/119076 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2092 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
5e83c2cc9c
commit
703fcecaaf
@ -53,6 +53,7 @@ devtools.profiler.ViewBuilder.prototype.buildView = function(
|
||||
callTree, opt_bottomUpViewWeights) {
|
||||
var head;
|
||||
var samplingRate = this.samplingRate;
|
||||
var createViewNode = this.createViewNode;
|
||||
callTree.traverse(function(node, viewParent) {
|
||||
var totalWeight = node.totalWeight * samplingRate;
|
||||
var selfWeight = node.selfWeight * samplingRate;
|
||||
@ -63,8 +64,7 @@ devtools.profiler.ViewBuilder.prototype.buildView = function(
|
||||
selfWeight = 0;
|
||||
}
|
||||
}
|
||||
var viewNode = new devtools.profiler.ProfileView.Node(
|
||||
node.label, totalWeight, selfWeight, head);
|
||||
var viewNode = createViewNode(node.label, totalWeight, selfWeight, head);
|
||||
if (viewParent) {
|
||||
viewParent.addChild(viewNode);
|
||||
} else {
|
||||
@ -72,11 +72,41 @@ devtools.profiler.ViewBuilder.prototype.buildView = function(
|
||||
}
|
||||
return viewNode;
|
||||
});
|
||||
var view = new devtools.profiler.ProfileView(head);
|
||||
var view = this.createView(head);
|
||||
return view;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Factory method for a profile view.
|
||||
*
|
||||
* @param {devtools.profiler.ProfileView.Node} head View head node.
|
||||
* @return {devtools.profiler.ProfileView} Profile view.
|
||||
*/
|
||||
devtools.profiler.ViewBuilder.prototype.createView = function(head) {
|
||||
return new devtools.profiler.ProfileView(head);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Factory method for a profile view node.
|
||||
*
|
||||
* @param {string} internalFuncName A fully qualified function name.
|
||||
* @param {number} totalTime Amount of time that application spent in the
|
||||
* corresponding function and its descendants (not that depending on
|
||||
* profile they can be either callees or callers.)
|
||||
* @param {number} selfTime Amount of time that application spent in the
|
||||
* corresponding function only.
|
||||
* @param {devtools.profiler.ProfileView.Node} head Profile view head.
|
||||
* @return {devtools.profiler.ProfileView.Node} Profile view node.
|
||||
*/
|
||||
devtools.profiler.ViewBuilder.prototype.createViewNode = function(
|
||||
funcName, totalTime, selfTime, head) {
|
||||
return new devtools.profiler.ProfileView.Node(
|
||||
funcName, totalTime, selfTime, head);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates a Profile View object. It allows to perform sorting
|
||||
* and filtering actions on the profile. Profile View mimicks
|
||||
@ -140,63 +170,12 @@ devtools.profiler.ProfileView.prototype.traverse = function(f) {
|
||||
*/
|
||||
devtools.profiler.ProfileView.Node = function(
|
||||
internalFuncName, totalTime, selfTime, head) {
|
||||
this.callIdentifier = 0;
|
||||
this.internalFuncName = internalFuncName;
|
||||
this.initFuncInfo();
|
||||
this.totalTime = totalTime;
|
||||
this.selfTime = selfTime;
|
||||
this.head = head;
|
||||
this.parent = null;
|
||||
this.children = [];
|
||||
this.visible = true;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* RegEx for stripping V8's prefixes of compiled functions.
|
||||
*/
|
||||
devtools.profiler.ProfileView.Node.FUNC_NAME_STRIP_RE =
|
||||
/^(?:LazyCompile|Function): (.*)$/;
|
||||
|
||||
|
||||
/**
|
||||
* RegEx for extracting script source URL and line number.
|
||||
*/
|
||||
devtools.profiler.ProfileView.Node.FUNC_NAME_PARSE_RE = /^([^ ]+) (.*):(\d+)$/;
|
||||
|
||||
|
||||
/**
|
||||
* RegEx for removing protocol name from URL.
|
||||
*/
|
||||
devtools.profiler.ProfileView.Node.URL_PARSE_RE = /^(?:http:\/)?.*\/([^/]+)$/;
|
||||
|
||||
|
||||
/**
|
||||
* Inits 'functionName', 'url', and 'lineNumber' fields using 'internalFuncName'
|
||||
* field.
|
||||
*/
|
||||
devtools.profiler.ProfileView.Node.prototype.initFuncInfo = function() {
|
||||
var nodeAlias = devtools.profiler.ProfileView.Node;
|
||||
this.functionName = this.internalFuncName;
|
||||
|
||||
var strippedName = nodeAlias.FUNC_NAME_STRIP_RE.exec(this.functionName);
|
||||
if (strippedName) {
|
||||
this.functionName = strippedName[1];
|
||||
}
|
||||
|
||||
var parsedName = nodeAlias.FUNC_NAME_PARSE_RE.exec(this.functionName);
|
||||
if (parsedName) {
|
||||
this.url = parsedName[2];
|
||||
var parsedUrl = nodeAlias.URL_PARSE_RE.exec(this.url);
|
||||
if (parsedUrl) {
|
||||
this.url = parsedUrl[1];
|
||||
}
|
||||
this.functionName = parsedName[1];
|
||||
this.lineNumber = parsedName[3];
|
||||
} else {
|
||||
this.url = '';
|
||||
this.lineNumber = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -273,10 +273,6 @@ TickProcessor.prototype.printStatistics = function() {
|
||||
this.printCounter(this.ticks_.unaccounted, this.ticks_.total);
|
||||
}
|
||||
|
||||
// Disable initialization of 'funcName', 'url', 'lineNumber' as
|
||||
// we don't use it and it just wastes time.
|
||||
devtools.profiler.ProfileView.Node.prototype.initFuncInfo = function() {};
|
||||
|
||||
var flatProfile = this.profile_.getFlatProfile();
|
||||
var flatView = this.viewBuilder_.buildView(flatProfile);
|
||||
// Sort by self time, desc, then by name, desc.
|
||||
|
Loading…
Reference in New Issue
Block a user