Web Inspector: speed-up Network panel. Change _staleResources type from array to...
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2011 11:59:27 +0000 (11:59 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2011 11:59:27 +0000 (11:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69081

There is a test with 30 requests.
For the each stage of loading a resource we have an entry in _staleResources array. There are at least 4 stages per request.
NetworkLogView._refresh function is creating/updating the resource row for the each such entry.
This array can be replaced with a hash map just because the resource associated with the entry is the same for all the entries with the same request id.

Reviewed by Pavel Feldman.

Test: inspector/performance/resources/network-append-30-requests.html

* inspector/front-end/NetworkPanel.js:
(WebInspector.NetworkLogView):
(WebInspector.NetworkLogView.prototype._invalidateAllItems):
(WebInspector.NetworkLogView.prototype.refresh):
(WebInspector.NetworkLogView.prototype._reset):
(WebInspector.NetworkLogView.prototype._refreshResource):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@96321 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/NetworkPanel.js

index bc6c973ad24b45696e2cbb1759c98d467b75523f..0fa39936ea36d5fe34c4f3ce03dbd0067bd16a40 100644 (file)
@@ -1,3 +1,24 @@
+2011-09-29  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: speed-up Network panel. Change _staleResources type from array to object.
+        https://bugs.webkit.org/show_bug.cgi?id=69081
+
+        There is a test with 30 requests.
+        For the each stage of loading a resource we have an entry in _staleResources array. There are at least 4 stages per request.
+        NetworkLogView._refresh function is creating/updating the resource row for the each such entry.
+        This array can be replaced with a hash map just because the resource associated with the entry is the same for all the entries with the same request id.
+
+        Reviewed by Pavel Feldman.
+
+        Test: inspector/performance/resources/network-append-30-requests.html
+
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkLogView):
+        (WebInspector.NetworkLogView.prototype._invalidateAllItems):
+        (WebInspector.NetworkLogView.prototype.refresh):
+        (WebInspector.NetworkLogView.prototype._reset):
+        (WebInspector.NetworkLogView.prototype._refreshResource):
+
 2011-09-28  Pavel Feldman  <pfeldman@google.com>
 
         Web Inspector: make inspector protocol validation a part of the build process.
index 555462095d70665c9e670c1b7fe7a162446b94a9..531cc4889344836f42fb0964adbc57e0bf7ccf02 100644 (file)
@@ -42,7 +42,7 @@ WebInspector.NetworkLogView = function(parentElement)
     this._resources = [];
     this._resourcesById = {};
     this._resourcesByURL = {};
-    this._staleResources = [];
+    this._staleResources = {};
     this._resourceGridNodes = {};
     this._lastResourceGridNodeId = 0;
     this._mainResourceLoadTime = -1;
@@ -578,7 +578,10 @@ WebInspector.NetworkLogView.prototype = {
 
     _invalidateAllItems: function()
     {
-        this._staleResources = this._resources.slice();
+        for (var i = 0; i < this._resources.length; ++i) {
+            var resource = this._resources[i];
+            this._staleResources[resource.requestId] = resource;
+        }
     },
 
     get calculator()
@@ -660,15 +663,14 @@ WebInspector.NetworkLogView.prototype = {
 
         this._removeAllNodeHighlights();
         var wasScrolledToLastRow = this._dataGrid.isScrolledToLastRow();
-        var staleItemsLength = this._staleResources.length;
         var boundariesChanged = false;
         if (this.calculator.updateBoundariesForEventTime) {
             boundariesChanged = this.calculator.updateBoundariesForEventTime(this._mainResourceLoadTime) || boundariesChanged;
             boundariesChanged = this.calculator.updateBoundariesForEventTime(this._mainResourceDOMContentTime) || boundariesChanged;
         }
 
-        for (var i = 0; i < staleItemsLength; ++i) {
-            var resource = this._staleResources[i];
+        for (var resourceId in this._staleResources) {
+            var resource = this._staleResources[resourceId];
             var node = this._resourceGridNode(resource);
             if (!node) {
                 // Create the timeline tree element and graph.
@@ -687,13 +689,12 @@ WebInspector.NetworkLogView.prototype = {
         if (boundariesChanged) {
             // The boundaries changed, so all item graphs are stale.
             this._invalidateAllItems();
-            staleItemsLength = this._staleResources.length;
         }
 
-        for (var i = 0; i < staleItemsLength; ++i)
-            this._resourceGridNode(this._staleResources[i]).refreshGraph(this.calculator);
+        for (var resourceId in this._staleResources)
+            this._resourceGridNode(this._staleResources[resourceId]).refreshGraph(this.calculator);
 
-        this._staleResources = [];
+        this._staleResources = {};
         this._sortItems();
         this._updateSummaryBar();
         this._dataGrid.updateWidths();
@@ -721,7 +722,7 @@ WebInspector.NetworkLogView.prototype = {
         this._resources = [];
         this._resourcesById = {};
         this._resourcesByURL = {};
-        this._staleResources = [];
+        this._staleResources = {};
         this._resourceGridNodes = {};
 
         if (this._dataGrid) {
@@ -782,7 +783,7 @@ WebInspector.NetworkLogView.prototype = {
 
     _refreshResource: function(resource)
     {
-        this._staleResources.push(resource);
+        this._staleResources[resource.requestId] = resource;
         this._scheduleRefresh();
     },