Jordi,

I took your freemarker and JSP code below and implemented it in three equivalent S2 actions that generated a list of 20 Offers. I then took some basic performance measurements with JMeter

Test settings:
Http get request directly to the action url
Thread Group: 50 threads, 1 second ramp up period, 100 loops
Gaussian random timer with 100ms deviation and 300ms constant delay offset
Each webapp deployed in the same Tomcat 5.5.17 server on a basic winxp box (* yes, this is a bad test environment, but at least it was consistent for the 3 cases)

Case1: Install of S2.0.6 with struts object factory, no optimisations, JSP result

Result: 5000 Samples, Throughput:  87.8 requests/sec  1139.71 KB/sec

Case2: Install of S2.0.6 with struts object factory, local template directory and freemarker template update delay of 60000, JSP result

Result: 5000 Samples, Throughput:  89.6 requests/sec  1213.35 KB/sec

Case3: Install of S2.0.6 with struts object factory, freemarker result

Result: 5000 Samples, Throughput:  73.7 requests/sec  579.12 KB/sec

Surprised?  I was.

The explanation for Case2 only being marginally faster than Case1 is that the JSP doesn't include any UIBeans (the templates are hardly used at all)

An explanation for why Case3 may be so much worse is that using struts tags within FTL is slower than using them directly in compiled JSP. As your sample doesn't make use of the UIBeans that use the freemarker templates its a disadvantage in this case to provide an FTL result.

Repeating the tests yielded consistent relative results on this server. I can't explain why these are not consistent with your test results.

regards,
Jeromy Evans

More details from JMeter:
Case1:
Samples: 5000
Average: 247
Median: 251
90% line: 319
Min: 0
Max: 721
Throughput:  87.8 requests/sec  1139.71 KB/sec

Case2:
Samples: 5000
Average: 234
Median: 235
90% line: 329
Min: 0
Max: 799
Throughput:  89.6 requests/sec  1213.35 KB/sec

Case3:
Samples: 5000
Average: 361
Median: 361
90% Line: 438
Min: 0
Max: 924
Throughput:  73.7 requests/sec  579.12 KB/sec


Jordi Rubio Moreno wrote:
Hi Jeromy,

 Is JSP taglib too slow and not recommended solution for production portals?

Hi Jordi, I'm impressed you made the effort to compare Freemarker vs Jsp performance. I've re-posted your question at the top of this email in the hope > that it gains the attention of some of the more experienced developers.

Thanks a lot! :) I hope this thread can open a sane discussion about 
performance, ticks and tips

In your test did you ensure your comparison doesn't include the first time the JSP 
is retrieved?  On the first request the JSP is converted to java and > then 
compiled which is inevitably slow.  Subsequent requests execute the bytecode and 
are much faster. Did you take this into account?

That's correct. I have compared both scenarios without considering the first 
JSP access (I know how JSP works at this level).

Thanks again for your time :)

Cheers

Jordi Rubio Moreno

-----Mensaje original-----
De: Jeromy Evans [mailto:[EMAIL PROTECTED] Enviado el: lunes, 28 de mayo de 2007 14:37
Para: Struts Users Mailing List
Asunto: Re: [S2] Freemarker vs struts taglibs

Jordi Rubio Moreno wrote:
 >  Is JSP taglib too slow and not recommended solution for production portals?

Hi Jordi, I'm impressed you made the effort to compare Freemarker vs Jsp 
performance.  I've re-posted your question at the top of this email in the hope 
that it gains the attention of some of the more experienced developers.

In your test did you ensure your comparison doesn't include the first time the 
JSP is retrieved?  On the first request the JSP is converted to java and then 
compiled which is inevitably slow.  Subsequent requests execute the bytecode 
and are much faster. Did you take this into account?

Within struts2, I think it would be a fair assumption that JSP will always be 
somewhat slower than pure Freemaker because the UIBeans are rendering using the 
Freemarker template engine anyway.  I wouldn't have imagined it would be <10% 
slower but have no evidence.  I'll try to run the same comparison if I get a spare 
moment.

Anyone else care to comment?

Jordi Rubio Moreno wrote:
Hi Jeromy,

I apologize to respond this email so late.

I've develop a little test portal (close in functionality to production 
portal), and I've notice that JSP taglib are slower that Freemarker equivalent 
page (I'm speaking about a JSP result page rendered in 1.2s and the same page 
rendered with freemarker in 600ms).

It's certain that there are a lot of JSP taglib documentation and S2 forums, 
but in a production site it's critical an excellent time response.

I don't know if I'm doing anything wrong... I show you a little fragment of 
test code in JSP taglibs an Freemarker:

***************** JSP taglibs **********************

        <s:iterator value="offers">
                <tr>
                        <td>
                                <s:url id="curUrl" action="Redirect" 
includeParams="none">
                                        <s:param name="url"><s:property 
value="offUrl"/></s:param>
                                </s:url>
                                <a href="${curUrl}"><s:property 
value="offTitle"/></a><br>
                                <s:if test="%{offCompany != null}">
                                        <b><s:text name="Results.company"/></b>:&nbsp;<s:property 
value="offCompany"/><br>
                                </s:if>
                                <s:if test="%{offSalary != null}">
                                        <b><s:text name="Results.salary"/></b>:&nbsp;<s:property 
value="offSalary"/><br>
                                </s:if>
                                <s:property value="offDescr"/><br>
                                <s:url id="addToShortListUrl" action="ShortList!add" 
includeParams="none">
                                        <s:param name="offId"><s:property 
value="offId"/></s:param>
                                </s:url>
                                <a href="${addToShortListUrl}"><s:text 
name="Results.addToShortList"/></a><br><br>
                        </td>
                </tr>
        </s:iterator>

******************** FREMARKER ************************


        <#list offers as o>
                <tr>
                        <td>
                                <@s.url id="curUrl" action="Redirect" includeParams="none" 
url="${o.offUrl}" />
                                <a href="${curUrl}">${o.offTitle}</a><br>
                                <#if o.offCompany != "">
                                        <b><@s.text 
name="Results.company"/></b>:&nbsp;${o.offCompany}<br>
                                </#if>
                                <#if o.offSalary != "">
                                        <b><@s.text 
name="Results.salary"/></b>:&nbsp;${o.offSalary}<br>
                                </#if>
                                ${o.offDescr}<br>
                                <@s.url id="addToShortListUrl" action="ShortList!add" 
includeParams="none" offId="${o.offId}" />
                                <a href="${addToShortListUrl}"><@s.text 
name="Results.addToShortList"/></a><br><br>
                        </td>
                </tr>
        </#list>


Is JSP taglib an slow and not recommended solution for production portals?

Thanks a lot for your patience :)

Best regards!

Jordi Rubio Moreno

-----Mensaje original-----
De: Jeromy Evans [mailto:[EMAIL PROTECTED]
Enviado el: sábado, 19 de mayo de 2007 6:13
Para: Struts Users Mailing List
Asunto: Re: [S2] Freemarker vs struts taglibs


If you're a new user of Struts2 and JSP then I suggest you simply start with 
JSP as there's far more resources and tutorials available.
You only must become aware of Freemarker once you wish to extend the default 
themes.

Within Struts2, by default Freemarker templates are used when rendering the UI 
components (ie. the S2 taglib classes that extend AbstractUITag such as 
TextField).
eg. if you use the <s:textfield> tag, Struts2 will render it using the text.ftl 
template for the specified/current theme.

Eventually you may wish to extend the theme (change with the way <s:textfield> 
is rendered) at which time you'll probably create your own templates for the UI 
components-of-interested and start using Freemarker.

Eventually may you also wish to create your own taglib UI components following 
the the S2 conventions in which case you'd follow the same template approach 
(but Struts2 does not preclude you from using any other JSP/taglib convention).

As mentioned in previous responses and the link below, Struts2 allows you to 
use entire Freemarker page results instead of JSP.  There are good technical 
arguments for using Freemarker instead of JSP, but generally speaking right now 
you'll find more people to help, initially less effort, more jobs and better 
IDE-support with JSP and almost everything you learn with JSP can be later be 
applied within the Freemarker context.

On 5/17/07, Musachy Barroso <[EMAIL PROTECTED]> wrote:
FreeMarker is a template engine, with it's own syntax. JSP tags can be used in FreeMarker, adding some configuration. In the case of Struts tags, no configuration is required, and you can use them like you would in JSP except a few differences, see this for details:

http://struts.apache.org/2.x/docs/freemarker.html

musachy

On 5/17/07, Jordi Rubio Moreno <[EMAIL PROTECTED]> wrote:
Hi,

I'm a bit confused. I need to decide if I'll use Freemarker or Struts taglibs, and I don't know the differences between both. E.g.
what's
the
difference between <s:iterator> and <@s.iterator>, <s:url> and
<@s.url>,
etc etc...

I have seen all the tutorials and examples I have found working with taglibs, but people says WebWork and Struts 2's choice is
Freemarker...
Please, help me to understand why taglibs or Freemarker :)

Thanks a lot!

Cheers!

--
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
-
--

No virus found in this incoming message.
Checked by AVG Free Edition. Version: 7.5.467 / Virus Database: 269.7.4/811 - Release Date: 18/05/2007 3:50 PM
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to