Bug 1061772 - Profiler cost percentage should be calculated based on number of samples and not samples delta time, r=pbrosset
authorVictor Porof <vporof@mozilla.com>
Fri, 19 Sep 2014 08:55:54 -0400
changeset 206240 30a7753deb4bda89d84600c6c9b37d2ec1d29210
parent 206239 c5247437d857469b0f280e125a95d2da73d40b13
child 206241 6ef192784187d7a477dfa402ce0a5b3a755d542e
push id27517
push userryanvm@gmail.com
push dateFri, 19 Sep 2014 18:13:39 +0000
treeherdermozilla-central@a084c4cfd8a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbrosset
bugs1061772
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1061772 - Profiler cost percentage should be calculated based on number of samples and not samples delta time, r=pbrosset
browser/devtools/profiler/test/browser_profiler_tree-view-01.js
browser/devtools/profiler/test/browser_profiler_tree-view-02.js
browser/devtools/profiler/utils/tree-model.js
browser/devtools/profiler/utils/tree-view.js
--- a/browser/devtools/profiler/test/browser_profiler_tree-view-01.js
+++ b/browser/devtools/profiler/test/browser_profiler_tree-view-01.js
@@ -34,17 +34,17 @@ function test() {
 
   is(container.childNodes[0].childNodes[1].getAttribute("type"), "percentage",
     "The root node in the tree has a percentage cell.");
   is(container.childNodes[0].childNodes[1].getAttribute("value"), "100%",
     "The root node in the tree has the correct percentage cell value.");
 
   is(container.childNodes[0].childNodes[2].getAttribute("type"), "samples",
     "The root node in the tree has an samples cell.");
-  is(container.childNodes[0].childNodes[2].getAttribute("value"), "",
+  is(container.childNodes[0].childNodes[2].getAttribute("value"), "3",
     "The root node in the tree has the correct samples cell value.");
 
   is(container.childNodes[0].childNodes[3].getAttribute("type"), "function",
     "The root node in the tree has a function cell.");
   is(container.childNodes[0].childNodes[3].style.MozMarginStart, "0px",
     "The root node in the tree has the correct indentation.");
 
   finish();
--- a/browser/devtools/profiler/test/browser_profiler_tree-view-02.js
+++ b/browser/devtools/profiler/test/browser_profiler_tree-view-02.js
@@ -26,17 +26,17 @@ function test() {
     "The container node should have one child available.");
   is(container.childNodes[0].className, "call-tree-item",
     "The root node in the tree has the correct class name.");
 
   is($$dur(0).getAttribute("value"), "18",
     "The root's duration cell displays the correct value.");
   is($$perc(0).getAttribute("value"), "100%",
     "The root's percentage cell displays the correct value.");
-  is($$sampl(0).getAttribute("value"), "",
+  is($$sampl(0).getAttribute("value"), "3",
     "The root's samples cell displays the correct value.");
   is($$fun(".call-tree-name")[0].getAttribute("value"), "(root)",
     "The root's function cell displays the correct name.");
   is($$fun(".call-tree-url")[0].getAttribute("value"), "",
     "The root's function cell displays the correct url.");
   is($$fun(".call-tree-line")[0].getAttribute("value"), "",
     "The root's function cell displays the correct line.");
   is($$fun(".call-tree-host")[0].getAttribute("value"), "",
@@ -79,17 +79,17 @@ function test() {
     "The container node should have four children available.");
   is(container.childNodes[2].className, "call-tree-item",
     "The .B node in the tree has the correct class name.");
   is(container.childNodes[3].className, "call-tree-item",
     "The .E node in the tree has the correct class name.");
 
   is($$dur(2).getAttribute("value"), "11",
     "The .A.B node's duration cell displays the correct value.");
-  is($$perc(2).getAttribute("value"), "61.11%",
+  is($$perc(2).getAttribute("value"), "66.66%",
     "The .A.B node's percentage cell displays the correct value.");
   is($$sampl(2).getAttribute("value"), "2",
     "The .A.B node's samples cell displays the correct value.");
   is($$fun(".call-tree-name")[2].getAttribute("value"), "B",
     "The .A.B node's function cell displays the correct name.");
   is($$fun(".call-tree-url")[2].getAttribute("value"), "baz",
     "The .A.B node's function cell displays the correct url.");
   ok($$fun(".call-tree-url")[2].getAttribute("tooltiptext").contains("http://foo/bar/baz"),
@@ -98,17 +98,17 @@ function test() {
     "The .A.B node's function cell displays the correct line.");
   is($$fun(".call-tree-host")[2].getAttribute("value"), "foo",
     "The .A.B node's function cell displays the correct host.");
   is($$fun(".call-tree-category")[2].getAttribute("value"), "Styles",
     "The .A.B node's function cell displays the correct category.");
 
   is($$dur(3).getAttribute("value"), "7",
     "The .A.E node's duration cell displays the correct value.");
-  is($$perc(3).getAttribute("value"), "38.88%",
+  is($$perc(3).getAttribute("value"), "33.33%",
     "The .A.E node's percentage cell displays the correct value.");
   is($$sampl(3).getAttribute("value"), "1",
     "The .A.E node's samples cell displays the correct value.");
   is($$fun(".call-tree-name")[3].getAttribute("value"), "E",
     "The .A.E node's function cell displays the correct name.");
   is($$fun(".call-tree-url")[3].getAttribute("value"), "baz",
     "The .A.E node's function cell displays the correct url.");
   ok($$fun(".call-tree-url")[3].getAttribute("tooltiptext").contains("http://foo/bar/baz"),
--- a/browser/devtools/profiler/utils/tree-model.js
+++ b/browser/devtools/profiler/utils/tree-model.js
@@ -47,16 +47,17 @@ exports._isContent = isContent; // used 
  * @param boolean contentOnly [optional]
  *        @see ThreadNode.prototype.insert
  * @param number beginAt [optional]
  *        @see ThreadNode.prototype.insert
  * @param number endAt [optional]
  *        @see ThreadNode.prototype.insert
  */
 function ThreadNode(threadSamples, contentOnly, beginAt, endAt) {
+  this.samples = 0;
   this.duration = 0;
   this.calls = {};
   this._previousSampleTime = 0;
 
   for (let sample of threadSamples) {
     this.insert(sample, contentOnly, beginAt, endAt);
   }
 }
@@ -92,16 +93,17 @@ ThreadNode.prototype = {
       rootIndex = 0;
     }
     if (!sampleFrames.length) {
       return;
     }
 
     let sampleDuration = sampleTime - this._previousSampleTime;
     this._previousSampleTime = sampleTime;
+    this.samples++;
     this.duration += sampleDuration;
 
     FrameNode.prototype.insert(
       sampleFrames, rootIndex, sampleTime, sampleDuration, this.calls);
   },
 
   /**
    * Gets additional details about this node.
--- a/browser/devtools/profiler/utils/tree-view.js
+++ b/browser/devtools/profiler/utils/tree-view.js
@@ -58,17 +58,17 @@ CallView.prototype = Heritage.extend(Abs
    * @param nsIDOMNode document
    * @param nsIDOMNode arrowNode
    * @return nsIDOMNode
    */
   _displaySelf: function(document, arrowNode) {
     this.document = document;
 
     let frameInfo = this.frame.getInfo();
-    let framePercentage = this.frame.duration / this.root.frame.duration * 100;
+    let framePercentage = this.frame.samples / this.root.frame.samples * 100;
 
     let durationCell = this._createTimeCell(this.frame.duration);
     let percentageCell = this._createExecutionCell(framePercentage);
     let samplesCell = this._createSamplesCell(this.frame.samples);
     let functionCell = this._createFunctionCell(arrowNode, frameInfo, this.level);
 
     let targetNode = document.createElement("hbox");
     targetNode.className = "call-tree-item";