John McNally wrote:
> 
> >
> > Now that you have this model, realize that with Velocity, you could have
> > avoided the entire exercise.  I think it will become clear why the
> > WM/Velocity way of doing things is much preferred.
> >
> > John McNally
> 
> I decided to test this quickly and wrote the test class below.
> 
> This probably doesn't prove anything but:
> Tests 1 and 3 which are fairly nonsensical show direct method to be 200X
> faster than reflection.
> 
> Test 2 includes a String concatenation in the method body and direct
> method is 7X faster.
> 
> Test 4 is fairly representative of many reflection calls where we are
> trying to display a simple property of an object.  And it shows the
> direct method to be 100X faster.
> 
> Please feel free to show me my errors.  But the article is probably
> correct in stating that FreeMarker is more efficient.  And I also still
> think the development time savings is worth it.

Reflection is very, very slow.  There is no doubt about that.  

We cache everything we can in Velocity :
- centrally, so we have the introspection information for the kinds of
objects are currently being used for a given reference in the template (
$foo.bar() ) across all threads, with quick access
- and also 'locally', such that for a given reference in a template, we
keep the introspection information for precisely what object you are
using in the context.  This is very efficient for loops and VMs, where
you revisit the same nodes again and again in execution.  Further, if
you can keep the Context object and reuse, you get the benefits of that
local caching on each execution throughout the template.

While I don't know for certain, I am sure that WebMacro caches this
stuff as well, althought I am not sure to what degree compared to
velocity.

This gives us what appears to be pretty good performance, and as John
and others have said, the development model is very efficient and
powerful.

geir

-- 
Geir Magnusson Jr.                               [EMAIL PROTECTED]
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to