Title: [172689] trunk/Source/WebInspectorUI
Revision
172689
Author
commit-qu...@webkit.org
Date
2014-08-16 02:25:27 -0700 (Sat, 16 Aug 2014)

Log Message

Web Inspector: Improve performance of selection range changes viewing Scripts timeline
https://bugs.webkit.org/show_bug.cgi?id=136015

Patch by Joseph Pecoraro <pecor...@apple.com> on 2014-08-16
Reviewed by Timothy Hatcher.

* UserInterface/Base/Utilities.js:
(clamp):
Helper function to clamp a value between a min and max.

* UserInterface/Models/ProfileNode.js:
(WebInspector.ProfileNode.prototype.get startTime):
(WebInspector.ProfileNode.prototype.get endTime):
These can be quickly calculated, so avoid full calculation to grab the values.

* UserInterface/Views/ScriptTimelineView.js:
(WebInspector.ScriptTimelineView.prototype.updateLayout):
Update ranges with a smart helper, instead of blindly doing it and needing refresh.

* UserInterface/Views/ProfileNodeDataGridNode.js:
(WebInspector.ProfileNodeDataGridNode.prototype.get rangeEndTime):
(WebInspector.ProfileNodeDataGridNode.prototype.get data):
(WebInspector.ProfileNodeDataGridNode.prototype.updateRangeTimes):
(WebInspector.ProfileNodeDataGridNode.prototype.set rangeStartTime): Deleted.
(WebInspector.ProfileNodeDataGridNode.prototype.set rangeEndTime): Deleted.
* UserInterface/Views/ScriptTimelineDataGridNode.js:
(WebInspector.ScriptTimelineDataGridNode.prototype.updateRangeTimes):
(WebInspector.ScriptTimelineDataGridNode.prototype.set rangeStartTime): Deleted.
(WebInspector.ScriptTimelineDataGridNode.prototype.set rangeEndTime): Deleted.
When updating the range selection, compare to the last range selection
on this DataGridNode. If the visible portion of this node's time range
changes, we need a refresh. Otherwise, we don't need a refresh.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (172688 => 172689)


--- trunk/Source/WebInspectorUI/ChangeLog	2014-08-16 05:49:19 UTC (rev 172688)
+++ trunk/Source/WebInspectorUI/ChangeLog	2014-08-16 09:25:27 UTC (rev 172689)
@@ -1,3 +1,37 @@
+2014-08-16  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Improve performance of selection range changes viewing Scripts timeline
+        https://bugs.webkit.org/show_bug.cgi?id=136015
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Base/Utilities.js:
+        (clamp):
+        Helper function to clamp a value between a min and max.
+
+        * UserInterface/Models/ProfileNode.js:
+        (WebInspector.ProfileNode.prototype.get startTime):
+        (WebInspector.ProfileNode.prototype.get endTime):
+        These can be quickly calculated, so avoid full calculation to grab the values.
+
+        * UserInterface/Views/ScriptTimelineView.js:
+        (WebInspector.ScriptTimelineView.prototype.updateLayout):
+        Update ranges with a smart helper, instead of blindly doing it and needing refresh.
+
+        * UserInterface/Views/ProfileNodeDataGridNode.js:
+        (WebInspector.ProfileNodeDataGridNode.prototype.get rangeEndTime):
+        (WebInspector.ProfileNodeDataGridNode.prototype.get data):
+        (WebInspector.ProfileNodeDataGridNode.prototype.updateRangeTimes):
+        (WebInspector.ProfileNodeDataGridNode.prototype.set rangeStartTime): Deleted.
+        (WebInspector.ProfileNodeDataGridNode.prototype.set rangeEndTime): Deleted.
+        * UserInterface/Views/ScriptTimelineDataGridNode.js:
+        (WebInspector.ScriptTimelineDataGridNode.prototype.updateRangeTimes):
+        (WebInspector.ScriptTimelineDataGridNode.prototype.set rangeStartTime): Deleted.
+        (WebInspector.ScriptTimelineDataGridNode.prototype.set rangeEndTime): Deleted.
+        When updating the range selection, compare to the last range selection
+        on this DataGridNode. If the visible portion of this node's time range
+        changes, we need a refresh. Otherwise, we don't need a refresh.
+
 2014-08-15  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: Update Scripts/update-LegacyInspectorBackendCommands.rb for the new generator

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js (172688 => 172689)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2014-08-16 05:49:19 UTC (rev 172688)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2014-08-16 09:25:27 UTC (rev 172689)
@@ -1015,6 +1015,11 @@
     }
 });
 
+function clamp(min, value, max)
+{
+    return Math.min(Math.max(min, value), max);
+}
+
 function insertionIndexForObjectInListSortedByFunction(object, list, comparator, insertionIndexAfter)
 {
     if (insertionIndexAfter) {

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/ProfileNode.js (172688 => 172689)


--- trunk/Source/WebInspectorUI/UserInterface/Models/ProfileNode.js	2014-08-16 05:49:19 UTC (rev 172688)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/ProfileNode.js	2014-08-16 09:25:27 UTC (rev 172689)
@@ -94,13 +94,15 @@
 
     get startTime()
     {
-        this._computeTotalTimesIfNeeded();
+        if (this._startTime === undefined)
+            this._startTime =  Math.max(0, this._calls[0].startTime);
         return this._startTime;
     },
 
     get endTime()
     {
-        this._computeTotalTimesIfNeeded();
+        if (this._endTime === undefined)
+            this._endTime = Math.min(this._calls.lastValue.endTime, Infinity);
         return this._endTime;
     },
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ProfileNodeDataGridNode.js (172688 => 172689)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ProfileNodeDataGridNode.js	2014-08-16 05:49:19 UTC (rev 172688)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ProfileNodeDataGridNode.js	2014-08-16 09:25:27 UTC (rev 172689)
@@ -68,32 +68,37 @@
         return this._rangeStartTime;
     },
 
-    set rangeStartTime(x)
+    get rangeEndTime()
     {
-        if (this._rangeStartTime === x)
-            return;
-
-        this._rangeStartTime = x;
-        this.needsRefresh();
+        return this._rangeEndTime;
     },
 
-    get rangeEndTime()
+    get data()
     {
-        return this._rangeEndTime;
+        return this._data;
     },
 
-    set rangeEndTime(x)
+    updateRangeTimes: function(startTime, endTime)
     {
-        if (this._rangeEndTime === x)
+        var oldRangeStartTime = this._rangeStartTime;
+        var oldRangeEndTime = this._rangeEndTime;
+
+        if (oldRangeStartTime === startTime && oldRangeEndTime === endTime)
             return;
 
-        this._rangeEndTime = x;
-        this.needsRefresh();
-    },
+        this._rangeStartTime = startTime;
+        this._rangeEndTime = endTime;
 
-    get data()
-    {
-        return this._data;
+        // We only need a refresh if the new range time changes the visible portion of this record.
+        var profileStart = this._profileNode.startTime;
+        var profileEnd = this._profileNode.endTime;
+        var oldStartBoundary = clamp(profileStart, oldRangeStartTime, profileEnd);
+        var oldEndBoundary = clamp(profileStart, oldRangeEndTime, profileEnd);
+        var newStartBoundary = clamp(profileStart, startTime, profileEnd);
+        var newEndBoundary = clamp(profileStart, endTime, profileEnd);
+
+        if (oldStartBoundary !== newStartBoundary || oldEndBoundary !== newEndBoundary)
+            this.needsRefresh();
     },
 
     refresh: function()

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineDataGridNode.js (172688 => 172689)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineDataGridNode.js	2014-08-16 05:49:19 UTC (rev 172688)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineDataGridNode.js	2014-08-16 09:25:27 UTC (rev 172689)
@@ -63,29 +63,11 @@
         return this._rangeStartTime;
     },
 
-    set rangeStartTime(x)
-    {
-        if (this._rangeStartTime === x)
-            return;
-
-        this._rangeStartTime = x;
-        this.needsRefresh();
-    },
-
     get rangeEndTime()
     {
         return this._rangeEndTime;
     },
 
-    set rangeEndTime(x)
-    {
-        if (this._rangeEndTime === x)
-            return;
-
-        this._rangeEndTime = x;
-        this.needsRefresh();
-    },
-
     get data()
     {
         var startTime = Math.max(this._rangeStartTime, this._record.startTime);
@@ -96,6 +78,33 @@
             averageTime: duration, callCount: 1, location: callFrameOrSourceCodeLocation};
     },
 
+    updateRangeTimes: function(startTime, endTime)
+    {
+        var oldRangeStartTime = this._rangeStartTime;
+        var oldRangeEndTime = this._rangeEndTime;
+
+        if (oldRangeStartTime === startTime && oldRangeEndTime === endTime)
+            return;
+
+        this._rangeStartTime = startTime;
+        this._rangeEndTime = endTime;
+        
+        // If we have no duration the range does not matter.
+        if (!this._record.duration)
+            return;
+
+        // We only need a refresh if the new range time changes the visible portion of this record.
+        var recordStart = this._record.startTime;
+        var recordEnd = this._record.startTime + this._record.duration;
+        var oldStartBoundary = clamp(recordStart, oldRangeStartTime, recordEnd);
+        var oldEndBoundary = clamp(recordStart, oldRangeEndTime, recordEnd);
+        var newStartBoundary = clamp(recordStart, startTime, recordEnd);
+        var newEndBoundary = clamp(recordStart, endTime, recordEnd);
+
+        if (oldStartBoundary !== newStartBoundary || oldEndBoundary !== newEndBoundary)
+            this.needsRefresh();
+    },
+
     createCellContent: function(columnIdentifier, cell)
     {
         const emptyValuePlaceholderString = "\u2014";

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineView.js (172688 => 172689)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineView.js	2014-08-16 05:49:19 UTC (rev 172688)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineView.js	2014-08-16 09:25:27 UTC (rev 172689)
@@ -112,8 +112,7 @@
         if (this.startTime !== this._oldStartTime || this.endTime !== this._oldEndTime) {
             var dataGridNode = this._dataGrid.children[0];
             while (dataGridNode) {
-                dataGridNode.rangeStartTime = this.startTime;
-                dataGridNode.rangeEndTime = this.endTime;
+                dataGridNode.updateRangeTimes(this.startTime, this.endTime);
                 if (dataGridNode.revealed)
                     dataGridNode.refreshIfNeeded();
                 dataGridNode = dataGridNode.traverseNextNode(false, null, true);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to