Changeset 53405 in webkit


Ignore:
Timestamp:
Jan 18, 2010 6:20:51 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-01-18 Alexander Pavlov <apavlov@chromium.org>

Reviewed by Pavel Feldman.

Improve Resources panel performance for lots of resources

DOM properties are extracted into const's, comparisons are faster.
https://bugs.webkit.org/show_bug.cgi?id=33790

  • inspector/front-end/AbstractTimelinePanel.js: (WebInspector.AbstractTimelinePanel.prototype._updateDividersLabelBarPosition):
  • inspector/front-end/Resource.js: (WebInspector.Resource.CompareByStartTime): (WebInspector.Resource.CompareByResponseReceivedTime): (WebInspector.Resource.CompareByEndTime): (WebInspector.Resource.CompareByDuration): (WebInspector.Resource.CompareByLatency): (WebInspector.Resource.CompareBySize):
  • inspector/front-end/ResourcesPanel.js: (WebInspector.ResourceGraph.prototype.refreshLabelPositions):
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53402 r53405  
     12010-01-18  Alexander Pavlov  <apavlov@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Improve Resources panel performance for lots of resources
     6
     7        DOM properties are extracted into const's, comparisons are faster.
     8        https://bugs.webkit.org/show_bug.cgi?id=33790
     9
     10        * inspector/front-end/AbstractTimelinePanel.js:
     11        (WebInspector.AbstractTimelinePanel.prototype._updateDividersLabelBarPosition):
     12        * inspector/front-end/Resource.js:
     13        (WebInspector.Resource.CompareByStartTime):
     14        (WebInspector.Resource.CompareByResponseReceivedTime):
     15        (WebInspector.Resource.CompareByEndTime):
     16        (WebInspector.Resource.CompareByDuration):
     17        (WebInspector.Resource.CompareByLatency):
     18        (WebInspector.Resource.CompareBySize):
     19        * inspector/front-end/ResourcesPanel.js:
     20        (WebInspector.ResourceGraph.prototype.refreshLabelPositions):
     21
    1222010-01-18  Daniel Bates  <dbates@rim.com>
    223
  • trunk/WebCore/inspector/front-end/AbstractTimelinePanel.js

    r51296 r53405  
    216216    _updateDividersLabelBarPosition: function()
    217217    {
    218         var scrollTop = this.containerElement.scrollTop;
    219         var dividersTop = (scrollTop < this.summaryBar.element.offsetHeight ? this.summaryBar.element.offsetHeight : scrollTop);
     218        const scrollTop = this.containerElement.scrollTop;
     219        const offsetHeight = this.summaryBar.element.offsetHeight;
     220        const dividersTop = (scrollTop < offsetHeight ? offsetHeight : scrollTop);
    220221        this._timelineGrid.setScrollAndDividerTop(scrollTop, dividersTop);
    221222    },
  • trunk/WebCore/inspector/front-end/Resource.js

    r52487 r53405  
    571571WebInspector.Resource.CompareByStartTime = function(a, b)
    572572{
    573     if (a.startTime < b.startTime)
    574         return -1;
    575     if (a.startTime > b.startTime)
    576         return 1;
    577     return 0;
     573    return a.startTime - b.startTime;
    578574}
    579575
    580576WebInspector.Resource.CompareByResponseReceivedTime = function(a, b)
    581577{
    582     if (a.responseReceivedTime === -1 && b.responseReceivedTime !== -1)
    583         return 1;
    584     if (a.responseReceivedTime !== -1 && b.responseReceivedTime === -1)
    585         return -1;
    586     if (a.responseReceivedTime < b.responseReceivedTime)
    587         return -1;
    588     if (a.responseReceivedTime > b.responseReceivedTime)
    589         return 1;
    590     return 0;
     578    var aVal = a.responseReceivedTime;
     579    var bVal = b.responseReceivedTime;
     580    if (aVal === -1 ^ bVal === -1)
     581        return bVal - aVal;
     582    return aVal - bVal;
    591583}
    592584
    593585WebInspector.Resource.CompareByEndTime = function(a, b)
    594586{
    595     if (a.endTime === -1 && b.endTime !== -1)
    596         return 1;
    597     if (a.endTime !== -1 && b.endTime === -1)
    598         return -1;
    599     if (a.endTime < b.endTime)
    600         return -1;
    601     if (a.endTime > b.endTime)
    602         return 1;
    603     return 0;
     587    var aVal = a.endTime;
     588    var bVal = b.endTime;
     589    if (aVal === -1 ^ bVal === -1)
     590        return bVal - aVal;
     591    return aVal - bVal;
    604592}
    605593
    606594WebInspector.Resource.CompareByDuration = function(a, b)
    607595{
    608     if (a.duration < b.duration)
    609         return -1;
    610     if (a.duration > b.duration)
    611         return 1;
    612     return 0;
     596    return a.duration - b.duration;
    613597}
    614598
    615599WebInspector.Resource.CompareByLatency = function(a, b)
    616600{
    617     if (a.latency < b.latency)
    618         return -1;
    619     if (a.latency > b.latency)
    620         return 1;
    621     return 0;
     601    return a.latency - b.latency;
    622602}
    623603
    624604WebInspector.Resource.CompareBySize = function(a, b)
    625605{
    626     if (a.contentLength < b.contentLength)
    627         return -1;
    628     if (a.contentLength > b.contentLength)
    629         return 1;
    630     return 0;
     606    return a.contentLength - b.contentLength;
    631607}
    632608
  • trunk/WebCore/inspector/front-end/ResourcesPanel.js

    r52547 r53405  
    11881188
    11891189        const labelPadding = 10;
    1190         const rightBarWidth = (this._barRightElement.offsetWidth - labelPadding);
    1191         const leftBarWidth = ((this._barLeftElement.offsetWidth - this._barRightElement.offsetWidth) - labelPadding);
    1192 
    1193         var labelBefore = (this._labelLeftElement.offsetWidth > leftBarWidth);
    1194         var labelAfter = (this._labelRightElement.offsetWidth > rightBarWidth);
     1190        const barRightElementOffsetWidth = this._barRightElement.offsetWidth;
     1191        const barLeftElementOffsetWidth = this._barLeftElement.offsetWidth;
     1192        const rightBarWidth = (barRightElementOffsetWidth - labelPadding);
     1193        const leftBarWidth = ((barLeftElementOffsetWidth - barRightElementOffsetWidth) - labelPadding);
     1194        const labelLeftElementOffsetWidth = this._labelLeftElement.offsetWidth;
     1195        const labelRightElementOffsetWidth = this._labelRightElement.offsetWidth;
     1196
     1197        const labelBefore = (labelLeftElementOffsetWidth > leftBarWidth);
     1198        const labelAfter = (labelRightElementOffsetWidth > rightBarWidth);
     1199        const graphElementOffsetWidth = this._graphElement.offsetWidth;
    11951200
    11961201        if (labelBefore) {
    1197             if ((this._graphElement.offsetWidth * (this._percentages.start / 100)) < (this._labelLeftElement.offsetWidth + 10))
     1202            if ((graphElementOffsetWidth * (this._percentages.start / 100)) < (labelLeftElementOffsetWidth + 10))
    11981203                this._labelLeftElement.addStyleClass("hidden");
    11991204            this._labelLeftElement.style.setProperty("right", (100 - this._percentages.start) + "%");
     
    12051210
    12061211        if (labelAfter) {
    1207             if ((this._graphElement.offsetWidth * ((100 - this._percentages.end) / 100)) < (this._labelRightElement.offsetWidth + 10))
     1212            if ((graphElementOffsetWidth * ((100 - this._percentages.end) / 100)) < (labelRightElementOffsetWidth + 10))
    12081213                this._labelRightElement.addStyleClass("hidden");
    12091214            this._labelRightElement.style.setProperty("left", this._percentages.end + "%");
Note: See TracChangeset for help on using the changeset viewer.