首頁 > 後端開發 > php教程 > php7 run

php7 run

WBOY
發布: 2016-06-23 13:32:38
原創
1823 人瀏覽過

/**
 * 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.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板