You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Jason Tesser <ja...@gmail.com> on 2010/03/09 18:17:47 UTC

Merge Template vs Parse

Can you help me understand the performance difference between
1. from Velocity calling #parse
2. doing a template.merge()

If I have a page that parses a bunch of VTLs which parse others and so forth
is it faster to do that all as a merge and not a parse.

We are seeing lots of different memory issues related to Velocity and I
wonder if Introspection is killing us. I was hoping one of the devs here
would have some idea.

Thanks,
Jason Tesser
dotCMS Lead Development Manager
1-305-858-1422

Re: Merge Template vs Parse

Posted by Nathan Bubna <nb...@gmail.com>.
On Tue, Mar 9, 2010 at 9:17 AM, Jason Tesser <ja...@gmail.com> wrote:
> Can you help me understand the performance difference between
> 1. from Velocity calling #parse

first calls out to the resource loader system to find the referenced
template (which may or may cache it on first call, depending on your
loaders).  Oh, and this also may have to run through an
IncludeEventHandler.   Then it goes on to render the template into the
parent writer.  Other differences are pretty negligible.

> 2. doing a template.merge()

Faster, mostly because you already have an init'ed template
(search/parse/cache/init already happened presumably).  And no
possibility of an IncludeEventHandler.

> If I have a page that parses a bunch of VTLs which parse others and so forth
> is it faster to do that all as a merge and not a parse.

Assuming all else is equal (context handling and whatnot), then, yes,
it should be slightly faster.

> We are seeing lots of different memory issues related to Velocity and I
> wonder if Introspection is killing us. I was hoping one of the devs here
> would have some idea.

There are so many configuration possibilities for Velocity that it is
hard to say.  Introspection is generally not a major bottleneck, so
long as you are not constantly creating new VelocityEngines (thus
ditching the ClassMap).   Memory problems were rather endemic in
Velocity 1.5, particularly where Velocimacros were concerned.  That
was fixed in 1.6.  But you would really need to profile and/or explain
more about your configuration and the nature of your templates to get
better help.

>
> Thanks,
> Jason Tesser
> dotCMS Lead Development Manager
> 1-305-858-1422
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org