Core code
<?php Class timer//page Execution time class {var starttime;//page start execution time var stoptime;//page end Execution time var spendtime;//page execution takes time function getmic Rotime ()//Gets the floating-point number {list (usec,sec) =explode ("", Microtime ()) that returns the current microseconds; Return ((float) usec + (float) sec); } function Start ()//page starts execution function, returns the start Page execution time {this->starttime=this->getmicrotime ();} function display ()// Displays the time the page was executed {this->stoptime=this->getmicrotime (); this->spendtime=this->stoptime-this->starttime; Return round (this->spendtime,10); }}/* Call Method Timer=new timer (); Timer->start (); /* Insert the script or code you want to execute here for (i=0;i<100000;i++) {echo i; echo.
"; } *///echo "
PHP detects each piece of code execution time
<?php//instance 1/** * @start time */function prostarttime () { global $startTime; $mtime 1 = Explode ("", Microtime ()); $startTime = $mtime 1[1] + $mtime 1[0];} /** * @End time */function proendtime () { global $startTime, $set; $mtime 2 = Explode ("", Microtime ()); $endtime = $mtime 2[1] + $mtime 2[0]; $totaltime = ($endtime-$startTime); $totaltime = Number_format ($totaltime, 7); echo "
Process time: ". $totaltime;} The program call begins when Prostarttime (); sleep (1); The sleep () delay code executes several seconds proendtime (); The execution time that the program consumes in each paragraph sleep (2);p roendtime (); Sleep (3);p roendtime (); /************************************************* Gorgeous split-line **************************************************/// Instance 2$t1 = Microtime (True), sleep (3), $t 2 = Microtime (true), echo ' program time consuming '. Round ($t 2-$t 1,3). ' Seconds ';? >
The above describes the httpcreditcard.bankcomm.com php a page execution time class code, including the httpcreditcard.bankcomm.com aspects of the content, I hope that the PHP tutorial interested in a friend helpful.