/**
* test.php ; compare php5.6.7 with php7.0.0alphal on time and memory by this simple program
*/
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = microtime_float();
$memory_start = memory_get_usage();
echo "Time start $time_start\n";
echo "Memory start $memory_start\n";
// Sleep for a while
//usleep(100);
$sum = 0;
for($i=1; $i {
$sum+=$i;
}
$i--;
echo "Sum(1+2+3+...+$i) = $sum\n";
$time_end = microtime_float();
$memory_end = memory_get_usage();
echo "Time end $time_end\n";
echo "Memory end $memory_end\n";
$time = $time_end - $time_start;
$memory = $memory_end - $memory_start;
//echo "Did nothing in $time seconds\n";
echo "Sub time $time seconds\n";
echo "Sub momory $memory byte\n";
?>
立即学习“PHP免费学习笔记(深入)”;
立即学习“PHP免费学习笔记(深入)”;
立即学习“PHP免费学习笔记(深入)”;
立即学习“PHP免费学习笔记(深入)”;
立即学习“PHP免费学习笔记(深入)”;
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号