Re: [SMARTY] Execution time of {eval ...}
| From: | Monte Ohrt | Date: | Tue, 06 Jul 2004 16:08:58 +0000 |
| Subject: | Re: [SMARTY] Execution time of {eval ...} | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11528@lists.php.net to get a copy of this message | ||
{capture} is using PHP output buffering functions and {eval} is using the PHP eval() function, so both of these are certainly going to show a performance hit. Most notably, eval() must generate op-code on the fly, no op-code accelerator is going to help any. You're better off avoiding eval, most certainly in a looping condition where performance is of importance.
Dennis Freise wrote:
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. ------------------------------------------------------------------------ !DSPAM:40eacaba62081498198962!