Created
November 4, 2011 16:40
-
-
Save joerayme/1339795 to your computer and use it in GitHub Desktop.
Loop test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$array = array_fill(0, 50000, 'a'); | |
$start = microtime(true); | |
for ($i = 0; $i < sizeof($array); $i++); | |
$end = microtime(true); | |
echo "Completed with sizeof in the loop in " . ($end - $start) . "s\n"; | |
$start = microtime(true); | |
for ($i = 0, $total = sizeof($array); $i < $total; $i++); | |
$end = microtime(true); | |
echo "Completed without sizeof in the loop in " . ($end - $start) . "s\n"; | |
// Output for me: | |
// Completed with sizeof in the loop in 0.0959849357605s | |
// Completed without sizeof in the loop in 0.01615691185s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment