On Tue, Oct 6, 2009 at 6:59 PM, Andrea Giammarchi <an_red@xxxxxxxxxxx> wrote: > > >> So while we can debate computing considerations of today, tomorrow >> those will be less important. That was the point I was making. Why >> not focus on things that make significant difference and let the >> insignificant fade into history. > > I tendentiously focus on all things able to make, all together, even more significant difference. > > Some micro-optimization, used as common code style, can make the entire application or the specific performance critical task, possible, even with an embed language as PHP is. > > ++$i is not different, from my point of view, from a code where each sequential push is performed via array_push($arr, $value) rather than $arr[] = $value; > Same is for all those loop such > for($i = 0; $i < count($staticStack); $i++); > > for me alien, since I've always done > > for($i = 0, $length = count($staticStack); $i < $length; ++$i); > > or, even better, a core performed loop when I need values > foreach($staticStack as $value); > > these are just examples, code style, whatever you want, and I'll never change my style unless there is a valid reason and some bench able to demonstrate I am wrong. I guess it's just a matter of point of views, but I cannot suggest slower practice cause Moore said tomorrow that CPU will strike the millisecond, 'cause on micro benchmarks, we can go faster, and that's it. > > Regards > > _________________________________________________________________ > Windows Live: Keep your friends up to date with what you do online. > http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010 And thus we have ANOTHER problem with PHP micro-optimizations; the proponents of using them are often misinformed or downright wrong about them. Two things you've mentioned in this thread, your count method and using string concatenation vs. string interpolation (' v. ") what you've proposed is actually slower! To wit: I can write a test[1] that comes out with these results: String concat time: 0.18807196617126 String interpolation time: 0.14288902282715 Where using " is faster than ' ! Common wisdom be damned! Similarly another test [2] shows that your count() method is less than microseconds faster per iteration. Note that these tests are actually run by codepad.org so I have no opportunity to fudge the results. [1] http://codepad.org/J2PRycef [2] http://codepad.org/7jFK9HHY The amount of time you spend making your code less readable and thinking about for microoptimizations, even if they are a habit, is going to be entirely wasted when your micro-optimization habits are rooted in falsehoods. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php