Created
November 16, 2010 05:03
-
-
Save dervn/701450 to your computer and use it in GitHub Desktop.
计算PHP脚本运行时间
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getmicrotime(){ | |
list($usec, $sec) = explode(" ",microtime()); | |
return ((float)$usec + (float)$sec); | |
} | |
//例子 | |
//开始 | |
$time_start = getmicrotime(); | |
//这里放你的代码 | |
//结束 | |
$time_end = getmicrotime(); | |
$time = $time_end - $time_start; | |
echo "Did nothing in $time seconds"; //输出运行总时间 | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment