Wicket
  1. Wicket
  2. WICKET-4015

Implement a listener which can be used to measure the render time of a component

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5-RC7
    • Fix Version/s: 1.5.1
    • Component/s: wicket, wicket-devutils
    • Labels:
      None

      Description

      It would be a nice addition to org.apache.wicket.markup.html.debug.PageView to show how much time it took for a component to be fully initialized and the time to be rendered. This can be accomplished with a listener which implements IComponentInstantiationListener, IComponentInitializationListener, IComponentOnBeforeRenderListener, IComponentOnAfterRenderListener.

      The initialization time measures from the call to Component.<init> (IComponentInstantiationListener), to the call Component.onInitialize() (IComponentInitializationListener) because there is no way to know when the component constructor ends.

      Render time measures the time between IComponentOnBeforeRenderListener.onBeforeRender() and IComponentOnAfterRenderListener.onAfterRender().

      The duration is collected in the meta data of the respective component.

      The listener will be part of wicket-devutils sub-project.

      Update: the instantiation time is not really useful in the way we can measure it so it wont be part of this feature request.

      1. WICKET-4015.patch
        9 kB
        Martin Grigorov

        Activity

        Hide
        Martin Grigorov added a comment -

        With r1165186 I added org.apache.wicket.devutils.inspector.RenderPerformanceListener.accepts(Component) that can filter which components' render time should be measured. By default only auto components are ignored.

        Show
        Martin Grigorov added a comment - With r1165186 I added org.apache.wicket.devutils.inspector.RenderPerformanceListener.accepts(Component) that can filter which components' render time should be measured. By default only auto components are ignored.
        Hide
        Igor Vaynberg added a comment -

        you are not going to add a behavior to every single component instance out there, are you?

        Show
        Igor Vaynberg added a comment - you are not going to add a behavior to every single component instance out there, are you?
        Martin Grigorov made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.5.1 [ 12315430 ]
        Resolution Fixed [ 1 ]
        Martin Grigorov made changes -
        Link This issue is blocked by WICKET-4012 [ WICKET-4012 ]
        Martin Grigorov made changes -
        Summary Implement a listener which can be used to measure the initialization and render times of a component Implement a listener which can be used to measure the render time of a component
        Description It would be a nice addition to org.apache.wicket.markup.html.debug.PageView to show how much time it took for a component to be fully initialized and the time to be rendered. This can be accomplished with a listener which implements IComponentInstantiationListener, IComponentInitializationListener, IComponentOnBeforeRenderListener, IComponentOnAfterRenderListener.

        The initialization time measures from the call to Component.<init> (IComponentInstantiationListener), to the call Component.onInitialize() (IComponentInitializationListener) because there is no way to know when the component constructor ends.

        Render time measures the time between IComponentOnBeforeRenderListener.onBeforeRender() and IComponentOnAfterRenderListener.onAfterRender().

        The duration is collected in the meta data of the respective component.

        The listener will be part of wicket-devutils sub-project.
        It would be a nice addition to org.apache.wicket.markup.html.debug.PageView to show how much time it took for a component to be fully initialized and the time to be rendered. This can be accomplished with a listener which implements IComponentInstantiationListener, IComponentInitializationListener, IComponentOnBeforeRenderListener, IComponentOnAfterRenderListener.

        The initialization time measures from the call to Component.<init> (IComponentInstantiationListener), to the call Component.onInitialize() (IComponentInitializationListener) because there is no way to know when the component constructor ends.

        Render time measures the time between IComponentOnBeforeRenderListener.onBeforeRender() and IComponentOnAfterRenderListener.onAfterRender().

        The duration is collected in the meta data of the respective component.

        The listener will be part of wicket-devutils sub-project.

        Update: the instantiation time is not really useful in the way we can measure it so it wont be part of this feature request.
        Component/s wicket [ 12311420 ]
        Hide
        Martin Grigorov added a comment -

        No need of OnPreRender/onPostRender listeners. All this is possible even now with Behavior.before/afterRender().

        Show
        Martin Grigorov added a comment - No need of OnPreRender/onPostRender listeners. All this is possible even now with Behavior.before/afterRender().
        Hide
        Martin Grigorov added a comment - - edited

        Unfortunately the produced numbers are not very meaningful with the current approaches.

        1) Initialization time problem
        Let's say we have a Page with constructor:

        { MyComponent c1 = new MyComponent("c1"); MyComponent c2 = new MyComponent("c2"); c1.add(c2) MyComponent c3 = new MyComponent("c3"); c2.add(c3); ... add(c1); }

        Here we start the measuring for c1 in its constructor but we will end the measuring at "add(c1)" call because at this point we will have the path to the Page and onInitialize() will be called. So c1's time will include the time of c2, c3, ... as well and wont be very accurate.

        2) Render time problem
        Wicket does something like:
        for (Component child : this)

        { child.onBeforeRender(); }

        for (Component child : this)

        { child.render(); }

        for (Component child : this)

        { child.onAfterRender(); }

        so we measure the whole time for all components, not just the component's onBefore->onAfter time.
        If we find this functionality useful then we will need to add yet another callbacks: onPreRender and onPostRender, i.e.:
        for (Component child : this)

        { getApplication().getOnPreRenderListeners().onPreRender(child); child.render(); getApplication().getOnPostRenderListeners().onPostRender(child); }

        This way each component will report its time and its parent will have a time which is a sum of all children + its own time.

        Show
        Martin Grigorov added a comment - - edited Unfortunately the produced numbers are not very meaningful with the current approaches. 1) Initialization time problem Let's say we have a Page with constructor: { MyComponent c1 = new MyComponent("c1"); MyComponent c2 = new MyComponent("c2"); c1.add(c2) MyComponent c3 = new MyComponent("c3"); c2.add(c3); ... add(c1); } Here we start the measuring for c1 in its constructor but we will end the measuring at "add(c1)" call because at this point we will have the path to the Page and onInitialize() will be called. So c1's time will include the time of c2, c3, ... as well and wont be very accurate. 2) Render time problem Wicket does something like: for (Component child : this) { child.onBeforeRender(); } for (Component child : this) { child.render(); } for (Component child : this) { child.onAfterRender(); } so we measure the whole time for all components, not just the component's onBefore->onAfter time. If we find this functionality useful then we will need to add yet another callbacks: onPreRender and onPostRender, i.e.: for (Component child : this) { getApplication().getOnPreRenderListeners().onPreRender(child); child.render(); getApplication().getOnPostRenderListeners().onPostRender(child); } This way each component will report its time and its parent will have a time which is a sum of all children + its own time.
        Martin Grigorov made changes -
        Attachment WICKET-4015.patch [ 12492583 ]
        Hide
        Martin Grigorov added a comment -

        Attaching the current version of the modifications I have locally.

        Show
        Martin Grigorov added a comment - Attaching the current version of the modifications I have locally.
        Hide
        Martin Grigorov added a comment -

        Due to the problem in WICKET-4012 for now IDetachListener.onDetach() is used instead of IComponentOnAfterRenderListener.onAfterRender().

        Show
        Martin Grigorov added a comment - Due to the problem in WICKET-4012 for now IDetachListener.onDetach() is used instead of IComponentOnAfterRenderListener.onAfterRender().
        Martin Grigorov made changes -
        Field Original Value New Value
        Link This issue is blocked by WICKET-4012 [ WICKET-4012 ]
        Martin Grigorov created issue -

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Martin Grigorov
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development