views:

220

answers:

1

We use Smarty and time to time it really takes a lot of time for it to render a template. Normally it works fine, but sometimes (like 1 random pageview out of 1 000) it takes about 5 seconds to render a template. We don't use smarty functions or plugins, just simple variables. What might be wrong, where to look? Templates are already compiled and they don't change before the 'slowdown'.

+1  A: 

Maybe not exactly what you're looking for, but still an answer:

If you're only working with variables and maybe simple loops and control structures, I'd recommend using another PHP-based template system. After all, PHP was designed to be a template language.

This approach has multiple positive sides:

  1. You don't have to learn yet another syntax.
  2. You lose the extra overhead of adding yet another layer on top of PHP, which in large parts duplicates what PHP can already do.
Franz
Yeah, implementing Smarty was big mistake, but we can't go back easily :-( see my question here http://stackoverflow.com/questions/436014/why-should-i-use-templating-system-in-php
Josef Sábl
I'd like to add that in my eyes even things like truncating an article preview or even converting 1000000 bytes to (about) 1 MB is presentation logic.And that kind of stuff gets really messy and ugly in Smarty.
Franz
Why would you be truncating a preview in smarty? That doesnt make any sense, you should do that in php?
Toby Allen
Why not? If a designer decides to suddenly show the complete article instead of just a truncated part, there's nothing he can do (on his own). Displaying all of a message or only part of it is presentation logic in my eyes - it has nothing to do with the flow of the program...
Franz