Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: tools/profile_view.js

Issue 115300: Merge into tools/profile_view.js changes needed for DevTools profiler. (Closed)
Patch Set: Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/profile_view.js
diff --git a/tools/profile_view.js b/tools/profile_view.js
index cd0511f6bae9e619dcf891bffa2ee4546bea4e21..9d196a37af4c3733b0a1c27c1ecef763d8f001c6 100644
--- a/tools/profile_view.js
+++ b/tools/profile_view.js
@@ -46,15 +46,25 @@ devtools.profiler.ViewBuilder = function(samplingRate) {
* Builds a profile view for the specified call tree.
*
* @param {devtools.profiler.CallTree} callTree A call tree.
+ * @param {boolean} opt_bottomUpViewWeights Whether remapping
+ * of self weights for a bottom up view is needed.
*/
devtools.profiler.ViewBuilder.prototype.buildView = function(
- callTree) {
+ callTree, opt_bottomUpViewWeights) {
var head;
var samplingRate = this.samplingRate;
callTree.traverse(function(node, viewParent) {
+ var totalWeight = node.totalWeight * samplingRate;
+ var selfWeight = node.selfWeight * samplingRate;
+ if (opt_bottomUpViewWeights === true) {
+ if (viewParent === head) {
+ selfWeight = totalWeight;
+ } else {
+ selfWeight = 0;
+ }
+ }
var viewNode = new devtools.profiler.ProfileView.Node(
- node.label, node.totalWeight * samplingRate,
- node.selfWeight * samplingRate, head);
+ node.label, totalWeight, selfWeight, head);
if (viewParent) {
viewParent.addChild(viewNode);
} else {
@@ -86,21 +96,6 @@ devtools.profiler.ProfileView = function(head) {
/**
- * Updates references between profiles. This is needed for WebKit
- * ProfileView.
- */
-devtools.profiler.ProfileView.prototype.updateProfilesRefs = function() {
- var profileNames = ["treeProfile", "heavyProfile", "flatProfile"];
- for (var i = 0; i < profileNames.length; ++i) {
- var destProfile = this[profileNames[i]];
- for (var j = 0; j < profileNames.length; ++j) {
- destProfile[profileNames[j]] = this[profileNames[j]];
- }
- }
-};
-
-
-/**
* Sorts the profile view using the specified sort function.
*
* @param {function(devtools.profiler.ProfileView.Node,
@@ -115,73 +110,6 @@ devtools.profiler.ProfileView.prototype.sort = function(sortFunc) {
/**
- * Sorts the profile view by self time, ascending.
- */
-devtools.profiler.ProfileView.prototype.sortSelfTimeAscending = function() {
- this.sort(function (node1, node2) {
- return node1.selfTime - node2.selfTime; });
-};
-
-
-/**
- * Sorts the profile view by self time, descending.
- */
-devtools.profiler.ProfileView.prototype.sortSelfTimeDescending = function() {
- this.sort(function (node1, node2) {
- return node2.selfTime - node1.selfTime; });
-};
-
-
-/**
- * Sorts the profile view by total time, ascending.
- */
-devtools.profiler.ProfileView.prototype.sortTotalTimeAscending = function() {
- this.sort(function (node1, node2) {
- return node1.totalTime - node2.totalTime; });
-};
-
-
-/**
- * Sorts the profile view by total time, descending.
- */
-devtools.profiler.ProfileView.prototype.sortTotalTimeDescending = function() {
- this.sort(function (node1, node2) {
- return node2.totalTime - node1.totalTime; });
-};
-
-
-/**
- * String comparator compatible with Array.sort requirements.
- *
- * @param {string} s1 First string.
- * @param {string} s2 Second string.
- */
-devtools.profiler.ProfileView.compareStrings = function(s1, s2) {
- return s1 < s2 ? -1 : (s1 > s2 ? 1 : 0);
-};
-
-
-/**
- * Sorts the profile view by function name, ascending.
- */
-devtools.profiler.ProfileView.prototype.sortFunctionNameAscending = function() {
- this.sort(function (node1, node2) {
- return devtools.profiler.ProfileView.compareStrings(
- node1.functionName, node2.functionName); });
-};
-
-
-/**
- * Sorts the profile view by function name, descending.
- */
-devtools.profiler.ProfileView.prototype.sortFunctionNameDescending = function() {
- this.sort(function (node1, node2) {
- return devtools.profiler.ProfileView.compareStrings(
- node2.functionName, node1.functionName); });
-};
-
-
-/**
* Traverses profile view nodes in preorder.
*
* @param {function(devtools.profiler.ProfileView.Node)} f Visitor function.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698