Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Iterator
<?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