Re: Replacing include with include_once in Smarty::fetch()?

boots <[email protected]>
Newsgroups gmane.comp.php.smarty.devel
Message-ID <[email protected]>
This is an interesting idea...but are you using a PHP accelerator? That
should speed-up includes considerably. Further, the scenario you
describe sounds hardly typical and even if you are generating many
emails in bulk (hmmmmmmmmmm) I would assume that you wouldn't be facing
many concurrent users but rather simply having to sporadically endure a
longer running process. In other words, optimizing here seems
unwarranted. Never-the-less, I think it would be possible to simulate
such an effect as you describe using messju's really cool compiler
plugin that you can find in this thread
http://www.phpinsider.com/smarty-forum/viewtopic.php?t=291 (which is on
recursion, but you need not use it recursively).

I don't mean to be impolite, but I sure hope this isn't some spam
related thing ;)

xo boots

--- Matthias Pigulla <[email protected]> wrote:

> Dear smarty-developers,
> 
> I'm extending a mailing application to allow for sending HTML emails.
> I
> use Smarty as template engine to build personalized e-mail messages
> (Smarty outputs html as well as text mime parts).
> 
> Right now, I'm doing some performance tests and have to call
> $smarty->fetch a few thousand times (once for every personalized
> e-mail
> being sent), which is a very realistic - if not even small - setup
> for
> my purposes.
> 
> The problem is that the include($_smarty_compile_path) around line
> 1258
> in Smarty.php makes up a huge share of total execution time and also
> consumes a lot of memory, although it just includes the same compiled
> template again and again. I could imagine that the PHP parser will
> analyze/precompile the file upon every inclusion? I'm not that
> familiar
> with PHP internals...
> 
> As a quick experiment, I wrote a postfilter to add "<?php function
> foo(&$this) { ?>" and "<? } ?>" around the compiled template and
> changed
> Smarty::fetch() to "include_**once**(...); foo($this);".
> 
> That way I could reduce the execution time spent in that code region
> to
> a fraction of 1/8th, memory consumption is reduced by about 3.5MB. I
> suppose that longer template code and more repetitions would even
> yield
> better improvements.
> 
> I know that usually you would hardly fetch the same template
> repeatedly
> during the same request, so maybe that problem only occurs with my
> very
> specific setup.
> 
> However, what do you think of automatically placing template code in
> a
> function body? The function name could be derived from the resource
> or
> file name. Note that this would require calling the function instead
> of
> just including the compiled template; however, as long as
> Smarty::fetch
> is the only section of code including templates, that should not be a
> problem.
> 
> Any ideas what else might break? Possible benefits?
> 
> Best regards,
> Matthias

-- 
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.