Php code running time viewing class code sharing _ PHP Tutorial

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

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.