Home > Backend Development > PHP Tutorial > PHP a page execution time code_PHP tutorial

PHP a page execution time code_PHP tutorial

WBOY
Release: 2016-07-21 15:40:20
Original
1028 people have browsed it

Copy code The code is as follows:

class Timer//Page execution time class
{
var starttime;//Page start execution time
var stoptime;//Page end execution time
var spendtime;//Page execution time spent
function getmicrotime()//Get the current microseconds returned Floating point number
{
list(usec,sec)=explode(" ",microtime());
return ((float)usec + (float)sec);
}
function start()//The page starts executing the function and returns the time when the page was executed
{
this->starttime=this->getmicrotime();
}
function display()// Display the page execution time
{
this->stoptime=this->getmicrotime();
this->spendtime=this->stoptime-this->starttime;
return round(this->spendtime,10);
}
}
/*Call method
timer=new Timer();
timer->start();
/*Put the script or code you want to execute here
for(i=0;i<100000;i++)
{
echo i;
echo "
" ;
}
*/
//echo "

It takes time to execute this code".timer->display()."seconds";
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321374.htmlTechArticleCopy the code as follows: ?php class Timer//Page execution time class { var starttime;//The page starts execution Time var stoptime;//Page end execution time var spendtime;//Page execution cost...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template