Skip to content

Instantly share code, notes, and snippets.

@ak4n
Forked from piotrpasich/iterator.php
Last active August 29, 2015 14:27
Show Gist options
  • Save ak4n/d750d7cca314edf9a551 to your computer and use it in GitHub Desktop.
Save ak4n/d750d7cca314edf9a551 to your computer and use it in GitHub Desktop.
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