On Thu, Feb 28, 2013 at 10:19 PM, tamouse mailing lists <tamouse.lists@xxxxxxxxx> wrote: > > Congratulations on ditching the Dreamweaver Templates! > > Now, as to preprocessing: how does this benchmark out? Have you > noticed a significant different in processing time, memory usage, disk > usage, etc? Well, it depends... For example, if you use code similar to the inlined function example, there is a difference. In that example, the inlined code runs almost twice as fast. <?php $a = 1; $b = 2; $start = microtime(); for ($i = 0; $i < 10000; $i++) { $result = ($a > $b && $a % 2 !== 0) ? $a : (($b % 2 !== 0) ? $b : (($a % 2 !== 0) ? $a : null)); } $runtime = microtime() - $start; echo $runtime; ?> <?php function maxodd($a, $b) { return ($a > $b && $a % 2 !== 0) ? $a : (($b % 2 !== 0) ? $b : (($a % 2 !== 0) ? $a : null)); } $a = 1; $b = 2; $start = microtime(); for ($i = 0; $i < 10000; $i++) { $result = maxodd($a, $b); } $runtime = microtime() - $start; echo $runtime; ?> That said, there's tremendous variance across the possible range of function types (e.g., number of args, complexity of function, etc.), so there's no guarantee you'll always see a worthwhile (which is also subjective) improvement. I'm going to use inlining for functions that output html-escaped output (the function wraps htmlspecialchars to allow whitelisting), as they're frequent and simple, the very type of function that is easily inlined and provides some speed benefit. In terms of the templating, in my tests using siege comparing Dreamweaver Templates vs PHP includes, I've typically seen significant benefits when the template requires multiple includes, with the effect dropping off as the number of includes approaches 0. These results should be the same. Again, there seems to be a broad range of considerations (in terms of using APC, using absolute paths helped the include performance: http://www.php.net/manual/en/apc.configuration.php#ini.apc.stat) There are usually bigger ways to enhance performance (data persistence, etc.), but in the same way that I try to teach my little girls to turn off the faucet in between spitting into the sink even though monitoring showers can do much more to save water, when I see simple ways I can consistently save cycles, I try to implement them :) Adam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php