Copy Code code as follows:
date:2011-08-05
Class runtime//page Execution time classes
{
private $starttime;//page Start execution time
private $stoptime;//page End Execution time
Private $spendtime//page execution takes time
function Getmicrotime ()//Gets the floating-point number that returns the current microsecond
{
List ($usec, $sec) =explode ("", Microtime ());
Return ((float) $usec + (float) $sec);
}
The function start ()//page begins execution functions, returning the start Page execution time
{
$this->starttime= $this->getmicrotime ();
}
function end ()//Display time of page execution
{
$this->stoptime= $this->getmicrotime ();
$this->spendtime= $this->stoptime-$this->starttime;
Return round ($this->spendtime,10);
}
function display ()
{
$this->end ();
echo "<p> Run Time:". Round ($this->spendtime,10). " SEC </p> ";
}
}
/* Call method
$timer =new Runtime ();
$timer->start ();