Created
January 27, 2015 06:59
-
-
Save piotrpasich/857cd0e4a0988e11a5f4 to your computer and use it in GitHub Desktop.
Iterator
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 | |
$start = microtime(true); | |
$mem = memory_get_usage(); | |
function t() { | |
global $argv; | |
$array = array(); | |
for ($i = 0; $i < $argv[1]; $i++) { | |
$array[] = rand(0, 100); | |
} | |
foreach ($array as $i => $a) { | |
if (0 == $a % 2) { | |
unset($array[$i]); | |
} | |
} | |
foreach ($array as $a) { | |
} | |
} | |
t(); | |
echo "Duration: " . (microtime(true) - $start) . "\n"; | |
echo "Memory: " . ((memory_get_usage() - $mem) / 1024 / 1024) . " MB"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment