]> source.dussan.org Git - vaadin-framework.git/commitdiff
Add more detailed profiling for some client side hotspots (#12418)
authorHenri Sara <hesara@vaadin.com>
Wed, 21 Aug 2013 07:45:54 +0000 (10:45 +0300)
committerVaadin Code Review <review@vaadin.com>
Wed, 21 Aug 2013 07:48:47 +0000 (07:48 +0000)
Change-Id: I27178a553571a99725ac4a75cae88d55398604ad

client/src/com/vaadin/client/LayoutManager.java
client/src/com/vaadin/client/ui/AbstractComponentConnector.java
client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java
client/src/com/vaadin/client/ui/panel/PanelConnector.java

index 14b155c92f5515b640a2365f44ed28575ca7f4de..1ced003146d9bfd2b3f03cf033b26f109b8365e9 100644 (file)
@@ -322,17 +322,22 @@ public class LayoutManager {
                     Collection<ElementResizeListener> listeners = elementResizeListeners
                             .get(element);
                     if (listeners != null) {
+                        Profiler.enter("Layout fire resize events - listeners not null");
+                        Profiler.enter("ElementResizeListener.onElementResize copy list");
                         ElementResizeListener[] array = listeners
                                 .toArray(new ElementResizeListener[listeners
                                         .size()]);
+                        Profiler.leave("ElementResizeListener.onElementResize copy list");
                         ElementResizeEvent event = new ElementResizeEvent(this,
                                 element);
                         for (ElementResizeListener listener : array) {
                             try {
                                 String key = null;
                                 if (Profiler.isEnabled()) {
-                                    key = "ElementReizeListener.onElementReize for "
+                                    Profiler.enter("ElementResizeListener.onElementResize construct profiler key");
+                                    key = "ElementResizeListener.onElementResize for "
                                             + Util.getSimpleName(listener);
+                                    Profiler.leave("ElementResizeListener.onElementResize construct profiler key");
                                     Profiler.enter(key);
                                 }
 
@@ -344,6 +349,7 @@ public class LayoutManager {
                                 VConsole.error(e);
                             }
                         }
+                        Profiler.leave("Layout fire resize events - listeners not null");
                     }
                 }
                 listenersToFire.clear();
@@ -716,13 +722,19 @@ public class LayoutManager {
     private void onConnectorChange(ComponentConnector connector,
             boolean widthChanged, boolean heightChanged) {
         Profiler.enter("LayoutManager.onConnectorChange");
+        Profiler.enter("LayoutManager.onConnectorChange setNeedsOverflowFix");
         setNeedsOverflowFix(connector);
+        Profiler.leave("LayoutManager.onConnectorChange setNeedsOverflowFix");
+        Profiler.enter("LayoutManager.onConnectorChange heightChanged");
         if (heightChanged) {
             currentDependencyTree.markHeightAsChanged(connector);
         }
+        Profiler.leave("LayoutManager.onConnectorChange heightChanged");
+        Profiler.enter("LayoutManager.onConnectorChange widthChanged");
         if (widthChanged) {
             currentDependencyTree.markWidthAsChanged(connector);
         }
+        Profiler.leave("LayoutManager.onConnectorChange widthChanged");
         Profiler.leave("LayoutManager.onConnectorChange");
     }
 
index d384549ee3d4ae99444652e757e94fe6bd611ed0..6f98e29d03449aa16eeba50ba93b62d47521e7d3 100644 (file)
@@ -150,17 +150,23 @@ public abstract class AbstractComponentConnector extends AbstractConnector
         }
         Profiler.leave("AbstractComponentConnector.onStateChanged update tab index");
 
+        Profiler.enter("AbstractComponentConnector.onStateChanged AbstractConnector.onStateChanged()");
         super.onStateChanged(stateChangeEvent);
+        Profiler.leave("AbstractComponentConnector.onStateChanged AbstractConnector.onStateChanged()");
 
         // Style names
+        Profiler.enter("AbstractComponentConnector.onStateChanged updateWidgetStyleNames");
         updateWidgetStyleNames();
+        Profiler.leave("AbstractComponentConnector.onStateChanged updateWidgetStyleNames");
 
         /*
          * updateComponentSize need to be after caption update so caption can be
          * taken into account
          */
 
+        Profiler.enter("AbstractComponentConnector.onStateChanged updateComponentSize");
         updateComponentSize();
+        Profiler.leave("AbstractComponentConnector.onStateChanged updateComponentSize");
 
         Profiler.enter("AbstractComponentContainer.onStateChanged check tooltip");
         if (!tooltipListenersAttached && hasTooltip()) {
index 2ce45623d09bad3ce24fad3a18f736fa6f9427f7..e148742b0b474cc0ef9d994d456974d60463d2dd 100644 (file)
@@ -26,6 +26,7 @@ import com.vaadin.client.FastStringMap;
 import com.vaadin.client.FastStringSet;
 import com.vaadin.client.HasComponentsConnector;
 import com.vaadin.client.JsArrayObject;
+import com.vaadin.client.Profiler;
 import com.vaadin.client.ServerConnector;
 import com.vaadin.client.Util;
 import com.vaadin.client.VConsole;
@@ -267,6 +268,7 @@ public class LayoutDependencyTree {
         }
 
         public void markSizeAsChanged() {
+            Profiler.enter("LayoutDependency.markSizeAsChanged phase 1");
             // When the size has changed, all that use that size should be
             // layouted
             JsArrayString needsSizeForLayout = getNeedsSizeForLayout();
@@ -276,14 +278,20 @@ public class LayoutDependencyTree {
                 LayoutDependency layoutDependency = getDependency(connectorId,
                         direction);
                 if (layoutDependency.connector instanceof ManagedLayout) {
+                    Profiler.enter("LayoutDependency.markSizeAsChanged setNeedsLayout");
                     layoutDependency.setNeedsLayout(true);
+                    Profiler.leave("LayoutDependency.markSizeAsChanged setNeedsLayout");
                 } else {
+                    Profiler.enter("LayoutDependency.markSizeAsChanged propagatePostLayoutMeasure");
                     // Should simulate setNeedsLayout(true) + markAsLayouted ->
                     // propagate needs measure
                     layoutDependency.propagatePostLayoutMeasure();
+                    Profiler.leave("LayoutDependency.markSizeAsChanged propagatePostLayoutMeasure");
                 }
             }
+            Profiler.leave("LayoutDependency.markSizeAsChanged phase 1");
 
+            Profiler.enter("LayoutDependency.markSizeAsChanged scrollbars");
             // Should also go through the hierarchy to discover appeared or
             // disappeared scrollbars
             ComponentConnector scrollingBoundary = getScrollingBoundary(connector);
@@ -291,6 +299,7 @@ public class LayoutDependencyTree {
                 getDependency(scrollingBoundary.getConnectorId(),
                         getOppositeDirection()).setNeedsMeasure(true);
             }
+            Profiler.leave("LayoutDependency.markSizeAsChanged scrollbars");
 
         }
 
@@ -332,22 +341,28 @@ public class LayoutDependencyTree {
         }
 
         private void propagatePostLayoutMeasure() {
+            Profiler.enter("LayoutDependency.propagatePostLayoutMeasure getResizedByLayout");
             JsArrayString resizedByLayout = getResizedByLayout();
+            Profiler.leave("LayoutDependency.propagatePostLayoutMeasure getResizedByLayout");
             int length = resizedByLayout.length();
             for (int i = 0; i < length; i++) {
+                Profiler.enter("LayoutDependency.propagatePostLayoutMeasure setNeedsMeasure");
                 String resizedId = resizedByLayout.get(i);
                 LayoutDependency layoutDependency = getDependency(resizedId,
                         direction);
                 layoutDependency.setNeedsMeasure(true);
+                Profiler.leave("LayoutDependency.propagatePostLayoutMeasure setNeedsMeasure");
             }
 
             // Special case for e.g. wrapping texts
+            Profiler.enter("LayoutDependency.propagatePostLayoutMeasure horizontal case");
             if (direction == HORIZONTAL && !connector.isUndefinedWidth()
                     && connector.isUndefinedHeight()) {
                 LayoutDependency dependency = getDependency(
                         connector.getConnectorId(), VERTICAL);
                 dependency.setNeedsMeasure(true);
             }
+            Profiler.leave("LayoutDependency.propagatePostLayoutMeasure horizontal case");
         }
 
         @Override
index fe211901c90dc8694c90fde45d4c76fe669b7bec..4011f86c76b6a3e307dc14b8f63467210da6c592 100644 (file)
@@ -23,6 +23,7 @@ import com.vaadin.client.ComponentConnector;
 import com.vaadin.client.ConnectorHierarchyChangeEvent;
 import com.vaadin.client.LayoutManager;
 import com.vaadin.client.Paintable;
+import com.vaadin.client.Profiler;
 import com.vaadin.client.UIDL;
 import com.vaadin.client.ui.AbstractSingleComponentContainerConnector;
 import com.vaadin.client.ui.ClickEventHandler;
@@ -194,22 +195,31 @@ public class PanelConnector extends AbstractSingleComponentContainerConnector
         VPanel panel = getWidget();
 
         LayoutManager layoutManager = getLayoutManager();
+        Profiler.enter("PanelConnector.layout getHeights");
         int top = layoutManager.getOuterHeight(panel.captionNode);
         int bottom = layoutManager.getInnerHeight(panel.bottomDecoration);
+        Profiler.leave("PanelConnector.layout getHeights");
 
+        Profiler.enter("PanelConnector.layout modify style");
         Style style = panel.getElement().getStyle();
         panel.captionNode.getParentElement().getStyle()
                 .setMarginTop(-top, Unit.PX);
         panel.bottomDecoration.getStyle().setMarginBottom(-bottom, Unit.PX);
         style.setPaddingTop(top, Unit.PX);
         style.setPaddingBottom(bottom, Unit.PX);
+        Profiler.leave("PanelConnector.layout modify style");
 
         // Update scroll positions
+        Profiler.enter("PanelConnector.layout update scroll positions");
         panel.contentNode.setScrollTop(panel.scrollTop);
         panel.contentNode.setScrollLeft(panel.scrollLeft);
+        Profiler.leave("PanelConnector.layout update scroll positions");
+
         // Read actual value back to ensure update logic is correct
+        Profiler.enter("PanelConnector.layout read scroll positions");
         panel.scrollTop = panel.contentNode.getScrollTop();
         panel.scrollLeft = panel.contentNode.getScrollLeft();
+        Profiler.leave("PanelConnector.layout read scroll positions");
     }
 
     @Override