Dashboard > WebWork 1 > WebWork CookBook > Webwork Performance Tips
  WebWork 1 Log In View a printable version of the current page.  
  Webwork Performance Tips
Added by Peter Kelley, last edited by Hani Suleiman on Apr 25, 2004  (view change)
Labels: 
(None)

Here's the place to share your secrets to obtaining blindingly fast WebWork performance.

Not that the discussion and hints below are obsolete and not relevant in the WW1.4 release.
You might still find the selectfastmap.jsp useful though.

-----------------------------------------------------------------------------
Peter Kelley made the following comment (somewhat reformatted) on Thu 23 January 2003:

OK I've been doing some numbers on performance and I thought I'd share
my results with the list.

The Page

The page I am testing is a page specifying search parameters for an item
search. It has 8 drop down lists, 6 of which have some rasonable data in
(days months and years for start and end). There is also a button and a
textfield. I started with all of the controls using the UI tags.

This page is going to an EJB server and getting data from a database so
some of the time shown here is not WW related.

The Methodology

Look at the clock by my desk and count how many whole seconds elapse
before the page renders. Do not count the initial page compile in the
data. Repeat 10 times and average the results.

Results

Webwork 1.2: 7.3 Seconds

Webwork 1.3RC2: 4.7 Seconds

Add the following to the page:

<% java.beans.PropertyEditorManager.registerEditor(String.class,
sun.beans.editors.StringEditor.class); %>

4.2 seconds

Replace ui:select with webwork:iterator: 4.1 seconds (no real
difference)

Replace ui:select with selectfastmap.jsp (see below)
using ui:component tags:

3.2 seconds

Caveat:

Selectfastmap.jsp requires a map when a lot of our data was in lists.
This is not a problem except that getting the map to provide the items
in the right order will become a little tricky. I am not sure if there is anything special performance wise about a map or whether selectfastmap.jsp can be rewritten easily to allow lists ?

Environment

Tomcat 4.1.18 running under JDK 1.4.1_01 talking RMI to JBoss 3.0.3
running under JDK 1.3.1_02 (JDK 1.4.1 was significantly faster than
1.3.1 for WW which was why the split was made). Versant Object database.

selectfastmap.jsp

<%@ page import="webwork.action.CoreActionContext,
                 java.util.Map,
                 java.util.Iterator"%>
 <%-
  - WebWork, Web Application Framework
  -
  - Distributable under LGPL license.
  - See terms of license at opensource.org
  -
  -
  - selectfastmap.jsp
  -
  - Required Parameters:
  -   * label  - The description that will be used to identfy the control.
  -   * name   - The name of the attribute to put and pull the result from.
  -              Equates to the NAME parameter of the HTML SELECT tag.
  -   * list   - Iterator that will provide the options for the control.
  -              Equates to the HTML OPTION tags in the SELECT and supplies
  -              both the NAME and VALUE parameters of the OPTION tag.
  -
  - Optional Parameters:
  -   * labelposition   - determines were the label will be place in relation
  -                       to the control.  Default is to the left of the control.
  -   * size            - SIZE parameter of the HTML SELECT tag.
  -   * disabled        - DISABLED parameter of the HTML SELECT tag.
  -   * tabindex        - tabindex parameter of the HTML SELECT tag.
  -   * onchange        - onkeyup parameter of the HTML SELECT tag.
  -   * size            - SIZE parameter of the HTML SELECT tag.
  -   * multiple        - MULTIPLE parameter of the HTML SELECT tag.
  -   * headerKey       - Combined with headerValue parameter specifies the top of select list
  -   * headerValue     - see above
  -
  -%>
<%@ taglib uri="webwork" prefix="webwork" %>
<%@ include file="controlheader.jsp" %>
<select name="<webwork:property value="parameters[OS:'name']"/>"
      <webwork:property value="parameters[OS:'id']">
         <webwork:if test=".">id="<webwork:property value="."/>"</webwork:if>
      </webwork:property>
      <webwork:property value="parameters[OS:'disabled']">
         <webwork:if test="parameters[OS:'disabled'] == true">disabled="disabled"</webwork:if>
      </webwork:property>
      <webwork:property value="parameters[OS:'size']">
         <webwork:if test=".">size="<webwork:property value="."/>"</webwork:if>
      </webwork:property>
      <webwork:property value="parameters[OS:'tabindex']">
         <webwork:if test=".">tabindex="<webwork:property value="."/>"</webwork:if>
      </webwork:property>
      <webwork:property value="parameters[OS:'onchange']">
         <webwork:if test=".">onchange="<webwork:property value="."/>"</webwork:if>
      </webwork:property>
      <webwork:property value="parameters[OS:'multiple']">
         <webwork:if test="parameters[OS:'multiple'] == true">multiple="multiple"</webwork:if>
      </webwork:property>
      <webwork:property value="parameters[OS:'width']">
         <webwork:if test=".">width="<webwork:property value="."/>"</webwork:if>
      </webwork:property>
      <webwork:property value="parameters[OS:'style']">
         <webwork:if test=".">style="<webwork:property value="."/>"</webwork:if>
      </webwork:property>
>

        <webwork:if test="parameters[OS:'required'] == 'true'">
                <span class="requiredLabel"><font color="red">*</font></span>
        </webwork:if>

    <webwork:if test="parameters[OS:'headerKey'] != null && parameters[OS:'headerValue'] != null">
       <option value="<webwork:property value="parameters[OS:'headerKey']"/>">
          <webwork:property value="parameters[OS:'headerValue']"/>
       </option>
    </webwork:if>
    <%
        Object o = CoreActionContext.getValueStack().findValue("parameters[OS:'nameValue']");
        Map map = (Map) CoreActionContext.getValueStack().findValue("parameters[OS:'list']");
        for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) {
            Map.Entry entry = (Map.Entry) iterator.next();
    %>
        <option value="<%= entry.getKey() %>"
            <% if (entry.getKey().equals(o)) { %>
                selected="selected"
            <% } %>
            ><%= entry.getValue() %></option>
    <%
        }
    %>
</select>
<%@ include file="controlfooter.jsp" %>

The PrefixActionFactoryProxy has been fixed in CVS so that one should not be an issue anymore (as soon as we get 1.3 out the door!)

The other tip about registering a StringEditor with the PropertyEditorManager will only improve performance if you are running the Webwork 1.2.1 version.

Posted by Anonymous at Jan 16, 2003 05:58 | Permalink

With the new 1.3 RC2 release there is a new interface for property editors: webwork.util.editor.FastPropertyEditor. It has 2 methods: getAsText and getAsValue.

If you have registered your own PropertyEditors with the PropertyEditorManager you should consider letting them implement the FastPropertyEditor interface.

If they do, then they will be cached in BeanUtil, instead of being looked up and instantiated using PropertyEditorManager all the time.

Posted by Anonymous at Jan 20, 2003 08:38 | Permalink
Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators