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

Side by Side Diff: webkit/glue/devtools/js/heap_profiler_panel.js

Issue 342076: DevTools Heap profiler: implement sorting. (Closed)
Patch Set: Fixed according to comments Created 11 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Heap profiler panel implementation. 6 * @fileoverview Heap profiler panel implementation.
7 */ 7 */
8 8
9 WebInspector.ProfilesPanel.prototype.addSnapshot = function(snapshot) { 9 WebInspector.ProfilesPanel.prototype.addSnapshot = function(snapshot) {
10 snapshot.title = WebInspector.UIString("Snapshot %d", snapshot.number); 10 snapshot.title = WebInspector.UIString("Snapshot %d", snapshot.number);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 { 92 {
93 this._profile = profile; 93 this._profile = profile;
94 }, 94 },
95 95
96 show: function(parentElement) 96 show: function(parentElement)
97 { 97 {
98 WebInspector.View.prototype.show.call(this, parentElement); 98 WebInspector.View.prototype.show.call(this, parentElement);
99 this.dataGrid.updateWidths(); 99 this.dataGrid.updateWidths();
100 }, 100 },
101 101
102 hide: function()
103 {
104 WebInspector.View.prototype.hide.call(this);
105 this._currentSearchResultIndex = -1;
106 },
107
102 resize: function() 108 resize: function()
103 { 109 {
104 if (this.dataGrid) 110 if (this.dataGrid)
105 this.dataGrid.updateWidths(); 111 this.dataGrid.updateWidths();
106 }, 112 },
107 113
108 refresh: function() 114 refresh: function()
109 { 115 {
110 this.dataGrid.removeChildren(); 116 this.dataGrid.removeChildren();
111 117
112 var children = this.snapshotDataGridList.children; 118 var children = this.snapshotDataGridList.children;
113 var count = children.length; 119 var count = children.length;
114 for (var index = 0; index < count; ++index) 120 for (var index = 0; index < count; ++index)
115 this.dataGrid.appendChild(children[index]); 121 this.dataGrid.appendChild(children[index]);
116 122
117 this._updateSummaryGraph(); 123 this._updateSummaryGraph();
118 }, 124 },
119 125
120 refreshShowAsPercents: function() 126 refreshShowAsPercents: function()
121 { 127 {
122 this._updatePercentButton(); 128 this._updatePercentButton();
123 this.refreshVisibleData(); 129 this.refreshVisibleData();
124 }, 130 },
125 131
132 _deleteSearchMatchedFlags: function(node)
133 {
134 delete node._searchMatchedConsColumn;
135 delete node._searchMatchedCountColumn;
136 delete node._searchMatchedSizeColumn;
137 delete node._searchMatchedCountDeltaColumn;
138 delete node._searchMatchedSizeDeltaColumn;
139 },
140
141 searchCanceled: function()
142 {
143 if (this._searchResults) {
144 for (var i = 0; i < this._searchResults.length; ++i) {
145 var profileNode = this._searchResults[i].profileNode;
146 this._deleteSearchMatchedFlags(profileNode);
147 profileNode.refresh();
148 }
149 }
150
151 delete this._searchFinishedCallback;
152 this._currentSearchResultIndex = -1;
153 this._searchResults = [];
154 },
155
156 performSearch: function(query, finishedCallback)
157 {
158 // Call searchCanceled since it will reset everything we need before doi ng a new search.
159 this.searchCanceled();
160
161 query = query.trimWhitespace();
162
163 if (!query.length)
164 return;
165
166 this._searchFinishedCallback = finishedCallback;
167
168 var helper = WebInspector.HeapSnapshotView.SearchHelper;
169
170 var operationAndNumber = helper.parseOperationAndNumber(query);
171 var operation = operationAndNumber[0];
172 var queryNumber = operationAndNumber[1];
173
174 var percentUnits = helper.percents.test(query);
175 var megaBytesUnits = helper.megaBytes.test(query);
176 var kiloBytesUnits = helper.kiloBytes.test(query);
177 var bytesUnits = helper.bytes.test(query);
178
179 var queryNumberBytes = (megaBytesUnits ? (queryNumber * 1024 * 1024) : ( kiloBytesUnits ? (queryNumber * 1024) : queryNumber));
180
181 function matchesQuery(heapSnapshotDataGridNode)
182 {
183 WebInspector.HeapSnapshotView.prototype._deleteSearchMatchedFlags(he apSnapshotDataGridNode);
184
185 if (percentUnits) {
186 heapSnapshotDataGridNode._searchMatchedCountColumn = operation(h eapSnapshotDataGridNode.countPercent, queryNumber);
187 heapSnapshotDataGridNode._searchMatchedSizeColumn = operation(he apSnapshotDataGridNode.sizePercent, queryNumber);
188 heapSnapshotDataGridNode._searchMatchedCountDeltaColumn = operat ion(heapSnapshotDataGridNode.countDeltaPercent, queryNumber);
189 heapSnapshotDataGridNode._searchMatchedSizeDeltaColumn = operati on(heapSnapshotDataGridNode.sizeDeltaPercent, queryNumber);
190 } else if (megaBytesUnits || kiloBytesUnits || bytesUnits) {
191 heapSnapshotDataGridNode._searchMatchedSizeColumn = operation(he apSnapshotDataGridNode.size, queryNumberBytes);
192 heapSnapshotDataGridNode._searchMatchedSizeDeltaColumn = operati on(heapSnapshotDataGridNode.sizeDelta, queryNumberBytes);
193 } else {
194 heapSnapshotDataGridNode._searchMatchedCountColumn = operation(h eapSnapshotDataGridNode.count, queryNumber);
195 heapSnapshotDataGridNode._searchMatchedCountDeltaColumn = operat ion(heapSnapshotDataGridNode.countDelta, queryNumber);
196 }
197
198 if (heapSnapshotDataGridNode.constructorName.hasSubstring(query, tru e))
199 heapSnapshotDataGridNode._searchMatchedConsColumn = true;
200
201 if (heapSnapshotDataGridNode._searchMatchedConsColumn ||
202 heapSnapshotDataGridNode._searchMatchedCountColumn ||
203 heapSnapshotDataGridNode._searchMatchedSizeColumn ||
204 heapSnapshotDataGridNode._searchMatchedCountDeltaColumn ||
205 heapSnapshotDataGridNode._searchMatchedSizeDeltaColumn) {
206 heapSnapshotDataGridNode.refresh();
207 return true;
208 }
209
210 return false;
211 }
212
213 var current = this.snapshotDataGridList.children[0];
214 var depth = 0;
215 var info = {};
216
217 // The second and subsequent levels of heap snapshot nodes represent ret ainers,
218 // so recursive expansion will be infinite, since a graph is being trave rsed.
219 // So default to a recursion cap of 2 levels.
220 var maxDepth = 2;
221
222 while (current) {
223 if (matchesQuery(current))
224 this._searchResults.push({ profileNode: current });
225 current = current.traverseNextNode(false, null, (depth >= maxDepth), info);
226 depth += info.depthChange;
227 }
228
229 finishedCallback(this, this._searchResults.length);
230 },
231
232 jumpToFirstSearchResult: WebInspector.CPUProfileView.prototype.jumpToFirstSe archResult,
233 jumpToLastSearchResult: WebInspector.CPUProfileView.prototype.jumpToLastSear chResult,
234 jumpToNextSearchResult: WebInspector.CPUProfileView.prototype.jumpToNextSear chResult,
235 jumpToPreviousSearchResult: WebInspector.CPUProfileView.prototype.jumpToPrev iousSearchResult,
236 showingFirstSearchResult: WebInspector.CPUProfileView.prototype.showingFirst SearchResult,
237 showingLastSearchResult: WebInspector.CPUProfileView.prototype.showingLastSe archResult,
238 _jumpToSearchResult: WebInspector.CPUProfileView.prototype._jumpToSearchResu lt,
239
126 refreshVisibleData: function() 240 refreshVisibleData: function()
127 { 241 {
128 var child = this.dataGrid.children[0]; 242 var child = this.dataGrid.children[0];
129 while (child) { 243 while (child) {
130 child.refresh(); 244 child.refresh();
131 child = child.traverseNextNode(false, null, true); 245 child = child.traverseNextNode(false, null, true);
132 } 246 }
133 this._updateSummaryGraph(); 247 this._updateSummaryGraph();
134 }, 248 },
135 249
136 _changeBase: function() { 250 _changeBase: function() {
137 if (this.baseSnapshot === WebInspector.HeapSnapshotProfileType.snapshots [this.baseSelectElement.selectedIndex]) 251 if (this.baseSnapshot === WebInspector.HeapSnapshotProfileType.snapshots [this.baseSelectElement.selectedIndex])
138 return; 252 return;
139 253
140 this._resetDataGridList(); 254 this._resetDataGridList();
141 this.refresh(); 255 this.refresh();
256
257 if (!this.currentQuery || !this._searchFinishedCallback || !this._search Results)
258 return;
259
260 // The current search needs to be performed again. First negate out prev ious match
261 // count by calling the search finished callback with a negative number of matches.
262 // Then perform the search again with the same query and callback.
263 this._searchFinishedCallback(this, -this._searchResults.length);
264 this.performSearch(this.currentQuery, this._searchFinishedCallback);
142 }, 265 },
143 266
144 _createSnapshotDataGridList: function() 267 _createSnapshotDataGridList: function()
145 { 268 {
146 if (this._snapshotDataGridList) 269 if (this._snapshotDataGridList)
147 delete this._snapshotDataGridList; 270 delete this._snapshotDataGridList;
148 271
149 this._snapshotDataGridList = new WebInspector.HeapSnapshotDataGridList(t his, this.baseSnapshot.entries, this.profile.entries); 272 this._snapshotDataGridList = new WebInspector.HeapSnapshotDataGridList(t his, this.baseSnapshot.entries, this.profile.entries);
150 return this._snapshotDataGridList; 273 return this._snapshotDataGridList;
151 }, 274 },
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 this.showSizeAsPercent = !currentState; 309 this.showSizeAsPercent = !currentState;
187 this.showCountDeltaAsPercent = !currentState; 310 this.showCountDeltaAsPercent = !currentState;
188 this.showSizeDeltaAsPercent = !currentState; 311 this.showSizeDeltaAsPercent = !currentState;
189 this.refreshShowAsPercents(); 312 this.refreshShowAsPercents();
190 }, 313 },
191 314
192 _resetDataGridList: function() 315 _resetDataGridList: function()
193 { 316 {
194 this.baseSnapshot = WebInspector.HeapSnapshotProfileType.snapshots[this. baseSelectElement.selectedIndex]; 317 this.baseSnapshot = WebInspector.HeapSnapshotProfileType.snapshots[this. baseSelectElement.selectedIndex];
195 var lastComparator = WebInspector.HeapSnapshotDataGridList.propertyCompa rator("size", false); 318 var lastComparator = WebInspector.HeapSnapshotDataGridList.propertyCompa rator("size", false);
196 if (this.snapshotDataGridList) { 319 if (this.snapshotDataGridList)
197 lastComparator = this.snapshotDataGridList.lastComparator; 320 lastComparator = this.snapshotDataGridList.lastComparator;
198 }
199 this.snapshotDataGridList = this._createSnapshotDataGridList(); 321 this.snapshotDataGridList = this._createSnapshotDataGridList();
200 this.snapshotDataGridList.sort(lastComparator, true); 322 this.snapshotDataGridList.sort(lastComparator, true);
201 }, 323 },
202 324
203 _sortData: function() 325 _sortData: function()
204 { 326 {
205 var sortAscending = this.dataGrid.sortOrder === "ascending"; 327 var sortAscending = this.dataGrid.sortOrder === "ascending";
206 var sortColumnIdentifier = this.dataGrid.sortColumnIdentifier; 328 var sortColumnIdentifier = this.dataGrid.sortColumnIdentifier;
207 var sortProperty = { 329 var sortProperty = {
208 "cons": "constructorName", 330 "cons": ["constructorName", null],
209 "count": "count", 331 "count": ["count", null],
210 "size": "size", 332 "size": ["size", "count"],
211 "countDelta": this.showCountDeltaAsPercent ? "countDeltaPercent" : "countDelta", 333 "countDelta": this.showCountDeltaAsPercent ? ["countDeltaPercent ", null] : ["countDelta", null],
212 "sizeDelta": this.showSizeDeltaAsPercent ? "sizeDeltaPercent" : "sizeDelta" 334 "sizeDelta": this.showSizeDeltaAsPercent ? ["sizeDeltaPercent", "countDeltaPercent"] : ["sizeDelta", "sizeDeltaPercent"]
213 }[sortColumnIdentifier]; 335 }[sortColumnIdentifier];
214 336
215 this.snapshotDataGridList.sort(WebInspector.HeapSnapshotDataGridList.pro pertyComparator(sortProperty, sortAscending)); 337 this.snapshotDataGridList.sort(WebInspector.HeapSnapshotDataGridList.pro pertyComparator(sortProperty[0], sortProperty[1], sortAscending));
216 338
217 this.refresh(); 339 this.refresh();
218 }, 340 },
219 341
220 _updateBaseOptions: function() 342 _updateBaseOptions: function()
221 { 343 {
222 var list = WebInspector.HeapSnapshotProfileType.snapshots; 344 var list = WebInspector.HeapSnapshotProfileType.snapshots;
223 // We're assuming that snapshots can only be added. 345 // We're assuming that snapshots can only be added.
224 if (this.baseSelectElement.length == list.length) 346 if (this.baseSelectElement.length == list.length)
225 return; 347 return;
(...skipping 18 matching lines...) Expand all
244 366
245 _updateSummaryGraph: function() 367 _updateSummaryGraph: function()
246 { 368 {
247 this.summaryBar.calculator.showAsPercent = this._isShowingAsPercent; 369 this.summaryBar.calculator.showAsPercent = this._isShowingAsPercent;
248 this.summaryBar.update(this.profile.lowlevels); 370 this.summaryBar.update(this.profile.lowlevels);
249 } 371 }
250 }; 372 };
251 373
252 WebInspector.HeapSnapshotView.prototype.__proto__ = WebInspector.View.prototype; 374 WebInspector.HeapSnapshotView.prototype.__proto__ = WebInspector.View.prototype;
253 375
376 WebInspector.HeapSnapshotView.SearchHelper = {
377 // In comparators, we assume that a value from a node is passed as the first parameter.
378 operations: { LESS: function (a, b) { return a !== null && a < b; },
379 LESS_OR_EQUAL: function (a, b) { return a !== null && a <= b; },
380 EQUAL: function (a, b) { return a !== null && a == b; },
381 GREATER_OR_EQUAL: function (a, b) { return a !== null && a >= b; },
382 GREATER: function (a, b) { return a !== null && a > b; } },
383
384 operationParsers: { LESS: /^<(\d+)/,
385 LESS_OR_EQUAL: /^<=(\d+)/,
386 GREATER_OR_EQUAL: /^>=(\d+)/,
387 GREATER: /^>(\d+)/ },
388
389 parseOperationAndNumber: function(query)
390 {
391 var operations = WebInspector.HeapSnapshotView.SearchHelper.operations;
392 var parsers = WebInspector.HeapSnapshotView.SearchHelper.operationParser s;
393 for (var operation in parsers) {
394 var match = query.match(parsers[operation]);
395 if (match != null)
396 return [operations[operation], parseFloat(match[1])];
397 }
398 return [operations.EQUAL, parseFloat(query)];
399 },
400
401 percents: /%$/,
402
403 megaBytes: /MB$/i,
404
405 kiloBytes: /KB$/i,
406
407 bytes: /B$/i
408 }
409
254 WebInspector.HeapSummaryCalculator = function(total) 410 WebInspector.HeapSummaryCalculator = function(total)
255 { 411 {
256 this.total = total; 412 this.total = total;
257 } 413 }
258 414
259 WebInspector.HeapSummaryCalculator.prototype = { 415 WebInspector.HeapSummaryCalculator.prototype = {
260 computeSummaryValues: function(lowLevels) 416 computeSummaryValues: function(lowLevels)
261 { 417 {
262 function highFromLow(type) { 418 function highFromLow(type) {
263 if (type == "CODE_TYPE" || type == "SHARED_FUNCTION_INFO_TYPE" || ty pe == "SCRIPT_TYPE") return "code"; 419 if (type == "CODE_TYPE" || type == "SHARED_FUNCTION_INFO_TYPE" || ty pe == "SCRIPT_TYPE") return "code";
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 else if (value === Number.NEGATIVE_INFINITY) 574 else if (value === Number.NEGATIVE_INFINITY)
419 return WebInspector.UIString("deleted"); 575 return WebInspector.UIString("deleted");
420 if (value > 1000.0) 576 if (value > 1000.0)
421 return WebInspector.UIString("%s >1000%%", this.signForDelta(value)) ; 577 return WebInspector.UIString("%s >1000%%", this.signForDelta(value)) ;
422 return WebInspector.UIString("%s%.2f%%", this.signForDelta(value), Math. abs(value)); 578 return WebInspector.UIString("%s%.2f%%", this.signForDelta(value), Math. abs(value));
423 }, 579 },
424 580
425 getTotalCount: function() { 581 getTotalCount: function() {
426 if (!this._count) { 582 if (!this._count) {
427 this._count = 0; 583 this._count = 0;
428 for (var i = 0, n = this.children.length; i < n; ++i) { 584 for (var i = 0, n = this.children.length; i < n; ++i)
429 this._count += this.children[i].count; 585 this._count += this.children[i].count;
430 }
431 } 586 }
432 return this._count; 587 return this._count;
433 }, 588 },
434 589
435 getTotalSize: function() { 590 getTotalSize: function() {
436 if (!this._size) { 591 if (!this._size) {
437 this._size = 0; 592 this._size = 0;
438 for (var i = 0, n = this.children.length; i < n; ++i) { 593 for (var i = 0, n = this.children.length; i < n; ++i)
439 this._size += this.children[i].size; 594 this._size += this.children[i].size;
440 }
441 } 595 }
442 return this._size; 596 return this._size;
443 }, 597 },
444 598
445 get countPercent() 599 get countPercent()
446 { 600 {
447 return this.count / this._parent.getTotalCount() * 100.0; 601 return this.count / this._parent.getTotalCount() * 100.0;
448 }, 602 },
449 603
450 get sizePercent() 604 get sizePercent()
(...skipping 16 matching lines...) Expand all
467 { 621 {
468 if (this.baseSize > 0) { 622 if (this.baseSize > 0) {
469 if (this.size > 0) 623 if (this.size > 0)
470 return this.sizeDelta / this.baseSize * 100.0; 624 return this.sizeDelta / this.baseSize * 100.0;
471 else 625 else
472 return Number.NEGATIVE_INFINITY; 626 return Number.NEGATIVE_INFINITY;
473 } else 627 } else
474 return Number.POSITIVE_INFINITY; 628 return Number.POSITIVE_INFINITY;
475 }, 629 },
476 630
477 getData: function(showSize) 631 get data()
478 { 632 {
479 var data = {}; 633 var data = {};
480 634
481 data["cons"] = this.constructorName; 635 data["cons"] = this.constructorName;
482 636
483 if (this.snapshotView.showCountAsPercent) 637 if (this.snapshotView.showCountAsPercent)
484 data["count"] = WebInspector.UIString("%.2f%%", this.countPercent); 638 data["count"] = WebInspector.UIString("%.2f%%", this.countPercent);
485 else 639 else
486 data["count"] = this.count; 640 data["count"] = this.count;
487 641
488 if (showSize) { 642 if (this.size !== null) {
489 if (this.snapshotView.showSizeAsPercent) 643 if (this.snapshotView.showSizeAsPercent)
490 data["size"] = WebInspector.UIString("%.2f%%", this.sizePercent) ; 644 data["size"] = WebInspector.UIString("%.2f%%", this.sizePercent) ;
491 else 645 else
492 data["size"] = Number.bytesToString(this.size); 646 data["size"] = Number.bytesToString(this.size);
493 } else { 647 } else
494 data["size"] = ""; 648 data["size"] = "";
495 }
496 649
497 if (this.snapshotView.showCountDeltaAsPercent) 650 if (this.snapshotView.showCountDeltaAsPercent)
498 data["countDelta"] = this.showDeltaAsPercent(this.countDeltaPercent) ; 651 data["countDelta"] = this.showDeltaAsPercent(this.countDeltaPercent) ;
499 else 652 else
500 data["countDelta"] = WebInspector.UIString("%s%d", this.signForDelta (this.countDelta), Math.abs(this.countDelta)); 653 data["countDelta"] = WebInspector.UIString("%s%d", this.signForDelta (this.countDelta), Math.abs(this.countDelta));
501 654
502 if (showSize) { 655 if (this.sizeDelta != null) {
503 if (this.snapshotView.showSizeDeltaAsPercent) 656 if (this.snapshotView.showSizeDeltaAsPercent)
504 data["sizeDelta"] = this.showDeltaAsPercent(this.sizeDeltaPercen t); 657 data["sizeDelta"] = this.showDeltaAsPercent(this.sizeDeltaPercen t);
505 else 658 else
506 data["sizeDelta"] = WebInspector.UIString("%s%s", this.signForDe lta(this.sizeDelta), Number.bytesToString(Math.abs(this.sizeDelta))); 659 data["sizeDelta"] = WebInspector.UIString("%s%s", this.signForDe lta(this.sizeDelta), Number.bytesToString(Math.abs(this.sizeDelta)));
507 } else { 660 } else
508 data["sizeDelta"] = ""; 661 data["sizeDelta"] = "";
509 }
510 662
511 return data; 663 return data;
664 },
665
666 createCell: function(columnIdentifier)
667 {
668 var cell = WebInspector.DataGridNode.prototype.createCell.call(this, col umnIdentifier);
669
670 if ((columnIdentifier === "cons" && this._searchMatchedConsColumn) ||
671 (columnIdentifier === "count" && this._searchMatchedCountColumn) ||
672 (columnIdentifier === "size" && this._searchMatchedSizeColumn) ||
673 (columnIdentifier === "countDelta" && this._searchMatchedCountDeltaC olumn) ||
674 (columnIdentifier === "sizeDelta" && this._searchMatchedSizeDeltaCol umn))
675 cell.addStyleClass("highlight");
676
677 return cell;
512 } 678 }
513 }; 679 };
514 680
515 WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype.__proto__ = WebInsp ector.DataGridNode.prototype; 681 WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype.__proto__ = WebInsp ector.DataGridNode.prototype;
516 682
517 WebInspector.HeapSnapshotDataGridNode = function(snapshotView, baseEntry, snapsh otEntry, owningTree) 683 WebInspector.HeapSnapshotDataGridNode = function(snapshotView, baseEntry, snapsh otEntry, owningTree)
518 { 684 {
519 this.snapshotView = snapshotView; 685 this.snapshotView = snapshotView;
520 686
521 if (!snapshotEntry) 687 if (!snapshotEntry)
522 snapshotEntry = { cons: baseEntry.cons, count: 0, size: 0, retainers: {} }; 688 snapshotEntry = { cons: baseEntry.cons, count: 0, size: 0, retainers: {} };
523 this.constructorName = snapshotEntry.cons; 689 this.constructorName = snapshotEntry.cons;
524 this.count = snapshotEntry.count; 690 this.count = snapshotEntry.count;
525 this.size = snapshotEntry.size; 691 this.size = snapshotEntry.size;
526 this.retainers = snapshotEntry.retainers; 692 this.retainers = snapshotEntry.retainers;
527 693
528 if (!baseEntry) 694 if (!baseEntry)
529 baseEntry = { count: 0, size: 0, retainers: {} }; 695 baseEntry = { count: 0, size: 0, retainers: {} };
530 this.baseCount = baseEntry.count; 696 this.baseCount = baseEntry.count;
531 this.countDelta = this.count - this.baseCount; 697 this.countDelta = this.count - this.baseCount;
532 this.baseSize = baseEntry.size; 698 this.baseSize = baseEntry.size;
533 this.sizeDelta = this.size - this.baseSize; 699 this.sizeDelta = this.size - this.baseSize;
534 this.baseRetainers = baseEntry.retainers; 700 this.baseRetainers = baseEntry.retainers;
535 701
536 WebInspector.HeapSnapshotDataGridNodeWithRetainers.call(this, owningTree); 702 WebInspector.HeapSnapshotDataGridNodeWithRetainers.call(this, owningTree);
537 }; 703 };
538 704
539 WebInspector.HeapSnapshotDataGridNode.prototype = {
540 get data()
541 {
542 return this.getData(true);
543 }
544 };
545
546 WebInspector.HeapSnapshotDataGridNode.prototype.__proto__ = WebInspector.HeapSna pshotDataGridNodeWithRetainers.prototype; 705 WebInspector.HeapSnapshotDataGridNode.prototype.__proto__ = WebInspector.HeapSna pshotDataGridNodeWithRetainers.prototype;
547 706
548 WebInspector.HeapSnapshotDataGridList = function(snapshotView, baseEntries, snap shotEntries) 707 WebInspector.HeapSnapshotDataGridList = function(snapshotView, baseEntries, snap shotEntries)
549 { 708 {
550 this.tree = this; 709 this.tree = this;
551 this.snapshotView = snapshotView; 710 this.snapshotView = snapshotView;
552 this.children = []; 711 this.children = [];
553 this.lastComparator = null; 712 this.lastComparator = null;
554 this.populateChildren(baseEntries, snapshotEntries); 713 this.populateChildren(baseEntries, snapshotEntries);
555 }; 714 };
(...skipping 23 matching lines...) Expand all
579 }, 738 },
580 739
581 produceDiff: WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype.pr oduceDiff, 740 produceDiff: WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype.pr oduceDiff,
582 sort: WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype.sort, 741 sort: WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype.sort,
583 getTotalCount: WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype. getTotalCount, 742 getTotalCount: WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype. getTotalCount,
584 getTotalSize: WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype.g etTotalSize 743 getTotalSize: WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype.g etTotalSize
585 }; 744 };
586 745
587 WebInspector.HeapSnapshotDataGridList.propertyComparators = [{}, {}]; 746 WebInspector.HeapSnapshotDataGridList.propertyComparators = [{}, {}];
588 747
589 WebInspector.HeapSnapshotDataGridList.propertyComparator = function(property, is Ascending) 748 WebInspector.HeapSnapshotDataGridList.propertyComparator = function(property, pr operty2, isAscending)
590 { 749 {
591 var comparator = this.propertyComparators[(isAscending ? 1 : 0)][property]; 750 var propertyHash = property + '#' + property2;
751 var comparator = this.propertyComparators[(isAscending ? 1 : 0)][propertyHas h];
592 if (!comparator) { 752 if (!comparator) {
593 comparator = function(lhs, rhs) { 753 comparator = function(lhs, rhs) {
594 var l = lhs[property], r = rhs[property]; 754 var l = lhs[property], r = rhs[property];
755 if ((l === null || r === null) && property2 !== null)
756 l = lhs[property2], r = rhs[property2];
595 var result = l < r ? -1 : (l > r ? 1 : 0); 757 var result = l < r ? -1 : (l > r ? 1 : 0);
596 return isAscending ? result : -result; 758 return isAscending ? result : -result;
597 }; 759 };
598 this.propertyComparators[(isAscending ? 1 : 0)][property] = comparator; 760 this.propertyComparators[(isAscending ? 1 : 0)][propertyHash] = comparat or;
599 } 761 }
600 return comparator; 762 return comparator;
601 }; 763 };
602 764
603 WebInspector.HeapSnapshotDataGridRetainerNode = function(snapshotView, baseEntry , snapshotEntry, owningTree) 765 WebInspector.HeapSnapshotDataGridRetainerNode = function(snapshotView, baseEntry , snapshotEntry, owningTree)
604 { 766 {
605 this.snapshotView = snapshotView; 767 this.snapshotView = snapshotView;
606 768
607 if (!snapshotEntry) 769 if (!snapshotEntry)
608 snapshotEntry = { cons: baseEntry.cons, count: 0, clusters: {} }; 770 snapshotEntry = { cons: baseEntry.cons, count: 0, clusters: {} };
609 this.constructorName = snapshotEntry.cons; 771 this.constructorName = snapshotEntry.cons;
610 this.count = snapshotEntry.count; 772 this.count = snapshotEntry.count;
611 this.retainers = this._calculateRetainers(this.snapshotView.profile, snapsho tEntry.clusters); 773 this.retainers = this._calculateRetainers(this.snapshotView.profile, snapsho tEntry.clusters);
612 774
613 if (!baseEntry) 775 if (!baseEntry)
614 baseEntry = { count: 0, clusters: {} }; 776 baseEntry = { count: 0, clusters: {} };
615 this.baseCount = baseEntry.count; 777 this.baseCount = baseEntry.count;
616 this.countDelta = this.count - this.baseCount; 778 this.countDelta = this.count - this.baseCount;
617 this.baseRetainers = this._calculateRetainers(this.snapshotView.baseSnapshot , baseEntry.clusters); 779 this.baseRetainers = this._calculateRetainers(this.snapshotView.baseSnapshot , baseEntry.clusters);
618 780
619 this.size = this.count; // This way, when sorting by sizes entries will be sorted by references count. 781 this.size = null;
782 this.sizeDelta = null;
620 783
621 WebInspector.HeapSnapshotDataGridNodeWithRetainers.call(this, owningTree); 784 WebInspector.HeapSnapshotDataGridNodeWithRetainers.call(this, owningTree);
622 } 785 }
623 786
624 WebInspector.HeapSnapshotDataGridRetainerNode.prototype = { 787 WebInspector.HeapSnapshotDataGridRetainerNode.prototype = {
625 get data() 788 get sizePercent()
626 { 789 {
627 return this.getData(false); 790 return null;
791 },
792
793 get sizeDeltaPercent()
794 {
795 return null;
628 }, 796 },
629 797
630 _calculateRetainers: function(snapshot, clusters) { 798 _calculateRetainers: function(snapshot, clusters) {
631 var retainers = {}; 799 var retainers = {};
632 if (this.isEmptySet(clusters)) { 800 if (this.isEmptySet(clusters)) {
633 if (this.constructorName in snapshot.entries) 801 if (this.constructorName in snapshot.entries)
634 return snapshot.entries[this.constructorName].retainers; 802 return snapshot.entries[this.constructorName].retainers;
635 } else { 803 } else {
636 // In case when an entry is retained by clusters, we need to gather up the list 804 // In case when an entry is retained by clusters, we need to gather up the list
637 // of retainers by merging retainers of every cluster. 805 // of retainers by merging retainers of every cluster.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 875
708 876
709 (function() { 877 (function() {
710 var originalCreatePanels = WebInspector._createPanels; 878 var originalCreatePanels = WebInspector._createPanels;
711 WebInspector._createPanels = function() { 879 WebInspector._createPanels = function() {
712 originalCreatePanels.apply(this, arguments); 880 originalCreatePanels.apply(this, arguments);
713 if (WebInspector.panels.profiles) 881 if (WebInspector.panels.profiles)
714 WebInspector.panels.profiles.registerProfileType(new WebInspector.He apSnapshotProfileType()); 882 WebInspector.panels.profiles.registerProfileType(new WebInspector.He apSnapshotProfileType());
715 } 883 }
716 })(); 884 })();
OLDNEW
« 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