For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > July 2004 > Execution time of {eval ...}









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Execution time of {eval ...}
Dennis Freise

2004-07-06, 4:11 pm

Hi everyone.

I've a question concerning the execution time of an {eval ...} command...

I have a site which uses many templates, and I have the following:

template 1:
{capture name=post_item}
{literal}
a typical post_block with {$vars} and {if expressions} in it
{/literal}
{/capture}

template 2:
{include file="template1"}
{section name=items loop=$post_items}
{eval var=$smarty.capture.post_item}
{/section}

Containing 10 posts on one page, this takes about 0.3 secs to compile on my
server.

If I change the templates to:

template 1:
a typical post_block with {$vars} and {if expressions} in it

template 2:
{section name=items loop=$post_items}
{include file="template1"}
{/section}

Now the page compiles in ~0.06 secs. Thats 5 times less than the
{capture}-{eval} approach.

Anyone who could clarify what's causing smarty to take so long to compile the
first variant, please ? Which one is to be preferred if the templates come from
a db, and the number of db-queries is important for performance ?

Thanks in advance, Dennis.

--
Dennis Freise <cat@final-frontier.ath.cx>
GnuPG key: 2DE8 CCEF 6E20 11D4 3B27 21EC B0BA 1749 D2C8 38ED
Available at: http://www.final-frontier.ath.cx/?key-plain

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com