httpcreditcard.bankcomm.com PHP A page execution time class code

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.