Php code run time to view class code sharing. Copy the code as follows: date: 2011-08-05classRunTime page execution time class {private $ starttime; page start execution time private $ stoptime; page end execution time priva
The code is as follows:
// Date: 2011-08-05
Class RunTime // page execution time class
{
Private $ starttime; // execution time of the page
Private $ stoptime; // page end execution time
Private $ spendtime; // time taken 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 end () // display the page execution time
{
$ This-> stoptime = $ this-> getmicrotime ();
$ This-> spendtime = $ this-> stoptime-$ this-> starttime;
// Return round ($ this-> spendtime, 10 );
}
Function display ()
{
// $ This-> end ();
Echo"
Run time: ". round ($ this-> spendtime, 10)." seconds
";
}
}
/* Call method
$ Timer = new Runtime ();
$ Timer-> start ();
Http://www.bkjia.com/PHPjc/324049.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/324049.htmlTechArticle code is as follows: // date: 2011-08-05 class RunTime // page execution time class {private $ starttime; // page execution start time private $ stoptime; // page end execution time priva...