Is there an actual difference between counting up between the for loop and the while loop?
+ 107 %
for($i = 0; $i < 1000000; ++$i); //Total time: 67620 µsview code
Is it worth the effort to calculate the length of the loop in advance?
e.g. "for ($i=0; $i<$size; $i++)" instead of "for ($i=0; $i<sizeOf($x); $i++)"
A loop with 1000 keys with 1 byte values are given.
+ 113 %
With pre calc - count()
Total time: 164 µsview code
+ 63104 %
Without pre calc - count()
Total time: 91625 µsview code
+ 100 %
With pre calc - sizeof()
Total time: 145 µsview code
+ 57806 %
Without pre calc - sizeof()
Total time: 83933 µsview code
Conclusion:
Unsurprising results... this is one of the easiest things to implement in any application and is the widest agreed upon benchmarking item within the online PHP community. The results basically speak for themselves.