Re: Reduce execution time in loops

From: Date: Tue, 04 Dec 2001 22:39:22 +0000
Subject: Re: Reduce execution time in loops
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2130@lists.php.net to get a copy of this message
> On Tue, 04 Dec 2001, Victor Boivie wrote: > > 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? > > Which lines did you remove exactly? $this->_sections["sl"]['properties']['rownum'] = $this->_sections["sl"]['properties']['iteration']; $this->_sections["sl"]['properties']['index_prev'] = $this->_sections["sl"]['properties']['index'] - $this->_sections["sl"]['properties']['step']; $this->_sections["sl"]['properties']['index_next'] = $this->_sections["sl"]['properties']['index'] + $this->_sections["sl"]['properties']['step']; $this->_sections["sl"]['properties']['first'] = ($this->_sections["sl"]['properties']['iteration'] == 1); $this->_sections["sl"]['properties']['last'] = ($this->_sections["sl"]['properties']['iteration'] == $this->_sections["sl"]['properties']['total']); On a few places. > Frankly, I have not heard anyone call Smarty slow, up to this point, I > guess. We always try to keep speed in mind, but it is difficult to > satisfy both those who crave features and those who want speed. No, it's not slow. Just not as fast as it could get. (Everything can always be improved...) Right now, the compiler in smarty isn't really a compiler, so it isn't to do speed improvements in the way "real" compilers (analyzing the code etc.. since smarty more or less replaces some code with other parts of code).. I'm well aware of that. But maybe you can add a flag or something? // Victor

« previous php.smarty.general (#2130) next »