PHP executes time code on a page. Copy the code as follows :? PhpclassTimer page execution time class {varstarttime; page start execution time varstoptime; page end execution time varspendtime; page execution cost
The code is as follows:
Class Timer // page execution time class
{
Var starttime; // the execution time of the page.
Var stoptime; // page end execution time
Var spendtime; // Time elapsed for page execution
Function getmicrotime () // gets the floating point number of the current microsecond.
{
List (usec, sec) = explode ("", microtime ());
Return (float) usec + (float) sec );
}
Function start () // start the execution of the function on the page, and return the execution time of the start page.
{
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 the code ". timer-> display ()." second ";
?>
The http://www.bkjia.com/PHPjc/321374.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/321374.htmlTechArticle code is as follows :? Php class Timer // page execution time class {var starttime; // page start execution time var stoptime; // page end execution time var spendtime; // page execution cost...