From b46cad28fb6efff625abc31e2eb85a38a854be6a Mon Sep 17 00:00:00 2001 From: Benoit Girard Date: Mon, 12 Mar 2012 20:08:19 -0400 Subject: [PATCH 1/6] Create treelist nodes on demand --- js/tree.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/tree.js b/js/tree.js index c9e9976af9..9657fe9022 100644 --- a/js/tree.js +++ b/js/tree.js @@ -145,6 +145,8 @@ TreeView.prototype = { var treeLine = document.createElement("div"); treeLine.className = "treeLine"; treeLine.innerHTML = this._HTMLForFunction(data); + // When this item is toggled we will expand its children + li.pendingExpand = []; li.treeLine = treeLine; li.data = data; li.appendChild(treeLine); @@ -154,7 +156,7 @@ TreeView.prototype = { var ol = document.createElement("ol"); ol.className = "treeViewNodeList"; for (var i = 0; i < data.children.length; ++i) { - this._pendingActions.push({parentElement: ol, parentNode: li, data: data.children[i].getData() }); + li.pendingExpand.push({parentElement: ol, parentNode: li, data: data.children[i].getData() }); } li.appendChild(ol); } @@ -171,7 +173,13 @@ TreeView.prototype = { '' + node.name + '' + '' + node.library + ''; }, + _resolveChild: function TreeView__resolveChild(div) { + while (div.pendingExpand != null && div.pendingExpand.length > 0) { + this._processOneAction(div.pendingExpand.shift()); + } + }, _toggle: function TreeView__toggle(div, /* optional */ newCollapsedValue, /* optional */ suppressScrollHeightNotification) { + this._resolveChild(div); if (newCollapsedValue === undefined) { div.classList.toggle("collapsed"); } else { From 90d85fb2182eced9235f3e5532c1da5380b2ec00 Mon Sep 17 00:00:00 2001 From: Benoit Girard Date: Mon, 12 Mar 2012 21:51:12 -0400 Subject: [PATCH 2/6] JankOnly stub --- js/parser.js | 6 +++++- js/ui.js | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/js/parser.js b/js/parser.js index b26c53e945..4700636fe9 100644 --- a/js/parser.js +++ b/js/parser.js @@ -162,7 +162,11 @@ var Parser = { return functionName; }, - filterByName: function Parse_filterByName(profile, filterName) { + filterByJank: function Parser_filterByJank(profile, filterThreshold) { + return profile; + }, + + filterByName: function Parser_filterByName(profile, filterName) { var samples = profile.samples.clone(); filterName = filterName.toLowerCase(); calltrace_it: for (var i = 0; i < samples.length; ++i) { diff --git a/js/ui.js b/js/ui.js index 95d6e80ca1..30b86194e0 100644 --- a/js/ui.js +++ b/js/ui.js @@ -725,6 +725,7 @@ function updateDescription() { infoText += "
\n"; infoText += "
\n"; infoText += "
\n"; + infoText += "
\n"; var filterNameInputOld = document.getElementById("filterName"); infoText += "
\n"; @@ -832,6 +833,16 @@ function toggleMergeFunctions() { refreshUI(); } +var gJankOnly = false; +var gJankThreshold = 50 /* ms */; +function toggleJank(/* optional */ threshold) { + gJankOnly = !gJankOnly; + if (threshold != null ) { + gJankThreshold = threshold; + } + refreshUI(); +} + function setHighlightedCallstack(samples) { gHighlightedCallstack = samples; gHistogramView.highlightedCallstackChanged(gHighlightedCallstack); @@ -869,6 +880,9 @@ function refreshUI() { if (filterNameInput != null && filterNameInput.value != "") { data = Parser.filterByName(data, document.getElementById("filterName").value); } + if (gJankOnly) { + data = Parser.filterByJank(data, gJankThreshold); + } if (gMergeFunctions) { data = Parser.discardLineLevelInformation(data); console.log("line information discarding: " + (Date.now() - start) + "ms."); From 7b48a28a5de54dace413ef07eecc3ebc8cdc954d Mon Sep 17 00:00:00 2001 From: Benoit Girard Date: Mon, 12 Mar 2012 22:35:24 -0400 Subject: [PATCH 3/6] Fix filterByName --- js/parser.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/parser.js b/js/parser.js index 4700636fe9..fef787a12c 100644 --- a/js/parser.js +++ b/js/parser.js @@ -173,7 +173,9 @@ var Parser = { var sample = samples[i]; var callstack = sample.frames; for (var j = 0; j < callstack.length; ++j) { - if (profile.symbols[callstack[j]].toLowerCase().indexOf(filterName) != -1) { + var symbol = profile.symbols[callstack[j]]; + if (symbol != null && + profile.symbols[callstack[j]].symbolName.toLowerCase().indexOf(filterName) != -1) { continue calltrace_it; } } From 2902104a5e88e9d6ca8884a4e7f805b205fa3c01 Mon Sep 17 00:00:00 2001 From: Benoit Girard Date: Mon, 12 Mar 2012 22:46:25 -0400 Subject: [PATCH 4/6] Remove clone+reverse in invert --- js/ui.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/js/ui.js b/js/ui.js index 30b86194e0..cfbcd20e76 100644 --- a/js/ui.js +++ b/js/ui.js @@ -250,13 +250,20 @@ HistogramView.prototype = { highlightedCallstack.length <= (gInvertCallstack ? 0 : 1)) continue next_iteration; - // TODO remove this clone, reverse the stack at build time. - var compareFrames = frames.clone(); - if (gInvertCallstack) - compareFrames.reverse(); - for (var j = 0; j < highlightedCallstack.length; j++) { - if (highlightedCallstack[j] != compareFrames[j] && compareFrames[j] != "(root)") - continue next_iteration; + if (gInvertCallstack) { + for (var j = 0; j < highlightedCallstack.length; j++) { + var compareFrameIndex = hlightedCallstack.length - j; + if (highlightedCallstack[j] != compareFrames[compareFrameIndex] && + compareFrames[compareFrameIndex] != "(root)") + continue next_iteration; + } + } else { + for (var j = 0; j < highlightedCallstack.length; j++) { + var compareFrameIndex = j; + if (highlightedCallstack[j] != compareFrames[compareFrameIndex] && + compareFrames[compareFrameIndex] != "(root)") + continue next_iteration; + } } return true; } @@ -818,7 +825,9 @@ function loadProfile(rawProfile) { var gInvertCallstack = false; function toggleInvertCallStack() { gInvertCallstack = !gInvertCallstack; + var startTime = Date.now(); refreshUI(); + console.log("invert time: " + (Date.now() - startTime) + "ms"); } var gMergeUnbranched = false; From 6ddbe8b7acb85b9e55f1394cffd3901ac6c85a39 Mon Sep 17 00:00:00 2001 From: Benoit Girard Date: Mon, 12 Mar 2012 22:57:37 -0400 Subject: [PATCH 5/6] Fix off by one and variable removal --- js/ui.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/ui.js b/js/ui.js index cfbcd20e76..ff6f08346c 100644 --- a/js/ui.js +++ b/js/ui.js @@ -250,9 +250,10 @@ HistogramView.prototype = { highlightedCallstack.length <= (gInvertCallstack ? 0 : 1)) continue next_iteration; + var compareFrames = frames; if (gInvertCallstack) { for (var j = 0; j < highlightedCallstack.length; j++) { - var compareFrameIndex = hlightedCallstack.length - j; + var compareFrameIndex = highlightedCallstack.length - 1 - j; if (highlightedCallstack[j] != compareFrames[compareFrameIndex] && compareFrames[compareFrameIndex] != "(root)") continue next_iteration; From b431dd8e661a7f400d3bc77f65cf6ec448347478 Mon Sep 17 00:00:00 2001 From: Benoit Girard Date: Mon, 12 Mar 2012 23:07:24 -0400 Subject: [PATCH 6/6] Support Jank Only --- js/parser.js | 14 +++++++++++++- js/ui.js | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/js/parser.js b/js/parser.js index fef787a12c..1274cc0669 100644 --- a/js/parser.js +++ b/js/parser.js @@ -163,7 +163,19 @@ var Parser = { }, filterByJank: function Parser_filterByJank(profile, filterThreshold) { - return profile; + var samples = profile.samples.clone(); + calltrace_it: for (var i = 0; i < samples.length; ++i) { + var sample = samples[i]; + if (sample.extraInfo["responsiveness"] < filterThreshold) { + samples[i] = samples[i].clone(); + samples[i].frames = ["Filtered out"]; + } + } + return { + symbols: profile.symbols, + functions: profile.functions, + samples: samples + }; }, filterByName: function Parser_filterByName(profile, filterName) { diff --git a/js/ui.js b/js/ui.js index ff6f08346c..008e4fc4cd 100644 --- a/js/ui.js +++ b/js/ui.js @@ -733,7 +733,7 @@ function updateDescription() { infoText += "
\n"; infoText += "
\n"; infoText += "
\n"; - infoText += "
\n"; + infoText += "
\n"; var filterNameInputOld = document.getElementById("filterName"); infoText += "
\n";