Title: [200745] trunk/Source/WebInspectorUI
- Revision
- 200745
- Author
- [email protected]
- Date
- 2016-05-12 00:23:53 -0700 (Thu, 12 May 2016)
Log Message
Web Inspector: 3.5% of time in toFixed in TimelineRecordBar updating element positions
https://bugs.webkit.org/show_bug.cgi?id=157608
Patch by Joseph Pecoraro <[email protected]> on 2016-05-12
Reviewed by Timothy Hatcher.
Avoid using toFixed to do an approximation comparison of two floating point numbers.
Instead keep in Numbers by just doing the approximation with Math.round(num * 100).
Since toFixed was doing stringification it was very expensive.
* UserInterface/Views/TimelineRecordBar.js:
(WebInspector.TimelineRecordBar.prototype._updateElementPosition):
(WebInspector.TimelineRecordBar):
* UserInterface/Views/TimelineRecordFrame.js:
(WebInspector.TimelineRecordFrame.prototype._updateElementPosition):
(WebInspector.TimelineRecordFrame):
* UserInterface/Views/TimelineRuler.js:
(WebInspector.TimelineRuler.prototype._updatePositionOfElement):
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (200744 => 200745)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-05-12 06:47:34 UTC (rev 200744)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-05-12 07:23:53 UTC (rev 200745)
@@ -1,3 +1,23 @@
+2016-05-12 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: 3.5% of time in toFixed in TimelineRecordBar updating element positions
+ https://bugs.webkit.org/show_bug.cgi?id=157608
+
+ Reviewed by Timothy Hatcher.
+
+ Avoid using toFixed to do an approximation comparison of two floating point numbers.
+ Instead keep in Numbers by just doing the approximation with Math.round(num * 100).
+ Since toFixed was doing stringification it was very expensive.
+
+ * UserInterface/Views/TimelineRecordBar.js:
+ (WebInspector.TimelineRecordBar.prototype._updateElementPosition):
+ (WebInspector.TimelineRecordBar):
+ * UserInterface/Views/TimelineRecordFrame.js:
+ (WebInspector.TimelineRecordFrame.prototype._updateElementPosition):
+ (WebInspector.TimelineRecordFrame):
+ * UserInterface/Views/TimelineRuler.js:
+ (WebInspector.TimelineRuler.prototype._updatePositionOfElement):
+
2016-05-11 Joseph Pecoraro <[email protected]>
Web Inspector: 4% of time in TimelineOverviewGraph adding/removing classList styles on TimelineRecordBar
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordBar.js (200744 => 200745)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordBar.js 2016-05-12 06:47:34 UTC (rev 200744)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordBar.js 2016-05-12 07:23:53 UTC (rev 200745)
@@ -336,11 +336,11 @@
_updateElementPosition(element, newPosition, property)
{
newPosition *= 100;
- newPosition = newPosition.toFixed(2);
- var currentPosition = parseFloat(element.style[property]).toFixed(2);
- if (currentPosition !== newPosition)
- element.style[property] = newPosition + "%";
+ let newPositionAprox = Math.round(newPosition * 100);
+ let currentPositionAprox = Math.round(parseFloat(element.style[property]) * 100);
+ if (currentPositionAprox !== newPositionAprox)
+ element.style[property] = (newPositionAprox / 100) + "%";
}
};
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordFrame.js (200744 => 200745)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordFrame.js 2016-05-12 06:47:34 UTC (rev 200744)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordFrame.js 2016-05-12 07:23:53 UTC (rev 200745)
@@ -272,11 +272,11 @@
_updateElementPosition(element, newPosition, property)
{
newPosition *= 100;
- newPosition = newPosition.toFixed(2);
- var currentPosition = parseFloat(element.style[property]).toFixed(2);
- if (currentPosition !== newPosition)
- element.style[property] = newPosition + "%";
+ let newPositionAprox = Math.round(newPosition * 100);
+ let currentPositionAprox = Math.round(parseFloat(element.style[property]) * 100);
+ if (currentPositionAprox !== newPositionAprox)
+ element.style[property] = (newPositionAprox / 100) + "%";
}
};
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js (200744 => 200745)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js 2016-05-12 06:47:34 UTC (rev 200744)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRuler.js 2016-05-12 07:23:53 UTC (rev 200745)
@@ -602,11 +602,11 @@
property = property || "left";
newPosition *= this._endTimePinned ? 100 : visibleWidth;
- newPosition = newPosition.toFixed(2);
- var currentPosition = parseFloat(element.style[property]).toFixed(2);
- if (currentPosition !== newPosition)
- element.style[property] = newPosition + (this._endTimePinned ? "%" : "px");
+ let newPositionAprox = Math.round(newPosition * 100);
+ let currentPositionAprox = Math.round(parseFloat(element.style[property]) * 100);
+ if (currentPositionAprox !== newPositionAprox)
+ element.style[property] = (newPositionAprox / 100) + (this._endTimePinned ? "%" : "px");
}
_updateMarkers(visibleWidth, duration)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes