Skip to content

Instantly share code, notes, and snippets.

@piotrpasich
Created January 27, 2015 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save piotrpasich/857cd0e4a0988e11a5f4 to your computer and use it in GitHub Desktop.
Save piotrpasich/857cd0e4a0988e11a5f4 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