Reduce execution time in loops
| From: | Victor Boivie | Date: | Tue, 04 Dec 2001 22:21:21 +0000 |
| Subject: | Reduce execution time in loops | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-2128@lists.php.net to get a copy of this message | ||
I have a sort of report generation script with many {section}s to render all the data I want to
show. Speed is very important to me, so I've tried to optimize my code as much as I can.
I don't need the nice variables as "iteration", "rownum",
"index_prev" etc in my code. I hardly need them at all even in my most advanced scripts!
So I tried to remove the lines for them from my already compiled tpl-file, and guess what happened?
The time it takes for PHP to render the file (not running my code.. just the template) decreased
from 302 -> 166 ms. That's a quite good speed gain, don't you think?
So I would like to add the ability to disable Smarty from adding these not-so-important lines in my
case. Section is just one example, and I think there should be quite many speed optimizations. The
new versions of Smarty has only become full of special functions that we rarely use. I think it
would be better to focus on the common things and try to make them better. A slow and bloated
template engine won't make anyone happy.
I don't mind if the compilation time will be ten times higher: I almost never compile the
files. (once per day at max).
Well, that was just my opinion. Flames are welcome
// Victor.