In the php benchmarking script, i am comparing 3 loops: FOR, WHILE and FOREACH. Amazingly, but not surprising, WHILE loop is the fastest compared to FOR and FOREACH, and as expected FOREACH is the slowest.
This is my output:
// for the FOR loop with 10000 times
// for the WHILE loop with 10000 times
// the number of elements in the array
// for the FOREACH loop with 10000 times
Note that the timings taken are an average of 5 runs spreaded across 5 mins (i.e. 1 run per minute) for the most accurate timings. Please note that the timings may differ from computer to computer. I am using Intel QuadCore 2.4GHz, 4GB RAM, Windows XP SP3, XAMPP 1.7.1, PHP 5.2.9.