Home >Backend Development >PHP Tutorial >httpcreditcard.bankcomm.com PHP a page execution time code

httpcreditcard.bankcomm.com PHP a page execution time code

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 08:42:021529browse

Core code

starttime=this->getmicrotime(); 
} 
function display()//显示页面执行的时间 
{ 
this->stoptime=this->getmicrotime(); 
this->spendtime=this->stoptime-this->starttime; 
return round(this->spendtime,10); 
} 
} 
/*调用方法 
timer=new Timer(); 
timer->start(); 
/*在此处放入你要执行的脚本或代码 
for(i=0;i"; 
} 
*/ 
//echo "<p>执行该代码花费时间".timer->display()."秒"; 
?> 
</p>

PHP detects the execution time of each piece of code

process time: ".$totaltime;
}

// 程序调用开始记时
proStartTime();

sleep(1);   // sleep() 延时代码执行若干秒
proEndTime(); // 程序在每一段所消耗的执行时间
sleep(2);
proEndTime();
sleep(3);
proEndTime(); 


/************************************************* 华丽的分割线 **************************************************/

// 实例2

$t1 = microtime(true);
sleep(3);
$t2 = microtime(true);
echo '程序耗时'.round($t2-$t1,3).'秒';

?>

The above introduces the httpcreditcard.bankcomm.com PHP page execution time code, including the content of httpcreditcard.bankcomm.com. I hope it will be helpful to friends who are interested in PHP tutorials.

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