Well, Mr.Packet's code sample brought to light something I didn't quite get right. Before I explain further...Weedpacket, I had to comment out this line.
$array = array_merge($array, $array);
My browser would seem to hang for a second, then go blank, and that was it. Nothing more (tested in Firefox 3.0.1 and Opera 9.51).
So with that aspect commented out, the snippet executes and sheds some additional light: even with the array being not so much the issue (due to being commented out), the number of cycles (loops) in conjunction to what goes on inside those loops definatelty matters (the heavier both factors become, I suspect the greater the discrepencies between for() methods becomes).
In anycase, it ran with interesting results..
Step 0: Timing for an array of length 1 Recalculating count(): 2.0980834960938E-5 seconds Precalculating count(): 1.1920928955078E-5 seconds Ratio: 1.76
but when I examine some of the steps (sometimes after refreshing (F5)), it seems the precalculated count is worse than the recalculated one:
Step 6: Timing for an array of length 1 Recalculating count(): 1.215934753418E-5 seconds Precalculating count(): 9.0599060058594E-6 seconds Ratio: 1.3421052631579
Is this a display error? Rounding off error? In either case, overall the results are pretty revealing (even with a small cycle (30 steps), and what goes on within those cycles (++p) and all this despite the array_merge causing issues.
Cheers,
NRG
Perhaps the effects would have been even further demonstrated had the array_merge function come into play?