diff --git a/tools/profile_view.js b/tools/profile_view.js index 9d196a37af..d0fc3b6d35 100644 --- a/tools/profile_view.js +++ b/tools/profile_view.js @@ -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; - } }; diff --git a/tools/tickprocessor.js b/tools/tickprocessor.js index 196daa984a..477ab26828 100644 --- a/tools/tickprocessor.js +++ b/tools/tickprocessor.js @@ -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.