Home  >  Article  >  Backend Development  >  How to calculate the execution time of a program_PHP Tutorial

How to calculate the execution time of a program_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:52:19770browse

function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec (float)$sec);
}

$time_start = getmicrotime();//Start timing and place it in the program header

for ($i=0; $i < 1000; $i ){
//do nothing, 1000 times
}

$time_end = getmicrotime();//End timing and put it at the end
$time = $time_end - $time_start;

echo "Did nothing in $time seconds";

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632500.htmlTechArticlefunction getmicrotime(){ list($usec, $sec) = explode( ,microtime()); return ( (float)$usec (float)$sec); } $time_start = getmicrotime();//Start timing and put it in the program header for ($i=0; $i...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn