ini_set('memory_limit', '999M');
ini_set('memory_warn', '500M');
ini_set('max_execution_time', '300');
function print_time($str, $isloop=false) {
$timer = microtime(true)*1000;
if (! isset($GLOBALS['timer_start'])) {
$GLOBALS['timer_start'] = $timer;
$GLOBALS['timer_last'] = $timer;
}
$diff = $timer-$GLOBALS['timer_last'];
if (isset($GLOBALS['timer_loopcost'])) {
$diff = $diff-$GLOBALS['timer_loopcost'];
}
if ($isloop) {
$GLOBALS['timer_loopcost'] = $diff-($diff*.05);
echo $GLOBALS['timer_loopcost']."\t\ttimer_loopcost (est)
\n";
}
print("$diff\t\t$str
\n");
$GLOBALS['timer_last'] = $timer;
}
$runs = 1000000;
print_time("start $runs");
$i=$runs; do {
} while ($i--);
print_time('loopinit', true);
$i=$runs; do {
$ary[$i] = 1;
} while ($i--);
print_time('alloc a bunch of stuff');