Author: [email protected]
Date: Wed Jun  3 04:21:23 2009
New Revision: 2092

Modified:
    branches/bleeding_edge/tools/profile_view.js
    branches/bleeding_edge/tools/tickprocessor.js

Log:
Make tickprocessor's ProfileView extensible and move out DevTools-only  
stuff.

Review URL: http://codereview.chromium.org/119076


Modified: branches/bleeding_edge/tools/profile_view.js
==============================================================================
--- branches/bleeding_edge/tools/profile_view.js        (original)
+++ branches/bleeding_edge/tools/profile_view.js        Wed Jun  3 04:21:23 2009
@@ -53,6 +53,7 @@
      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 @@
          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,12 +72,42 @@
      }
      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
   * the Profile object from WebKit's JSC profiler.
@@ -140,63 +170,12 @@
   */
  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;
-  }
  };



Modified: branches/bleeding_edge/tools/tickprocessor.js
==============================================================================
--- branches/bleeding_edge/tools/tickprocessor.js       (original)
+++ branches/bleeding_edge/tools/tickprocessor.js       Wed Jun  3 04:21:23 2009
@@ -273,10 +273,6 @@
      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.

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to