PHP getting script runtime _ PHP Tutorial

Source: Internet
Author: User
PHP obtains the script running time. Header (content-type: texthtml; charsetutf-8); microtime-returns the current Unix timestamp and number of microseconds $ oldtimemicrotime (true); echo the script running time:; $ v0; for ($ I

Header ("content-type: text/html; charset = utf-8 ");

// Microtime-returns the current Unix timestamp and number of microseconds

$ Oldtime = microtime (true );

Echo "the script running time is :";

$ V = 0;

For ($ I = 0; I I <100; $ I ++ ){

$ V ++;

}

$ Newtime = microtime (true );

// Obtain the time difference

$ Runtime = $ newtime-$ oldtime;

// Change the timestamp to a string-var_export output or return a string representation of a variable

$ Runtime = var_export ($ runtime );

// Truncates the string substr_count to calculate the number of times the string appears

$ Postion = substr_count ($ runtime, 'E ');

$ Runtime = substr ($ runtime, 0, $ postion-1 );

// Convert the string value to floatfloatval-get the floating point value of the variable

$ Running time = floatval ($ runtime)/1000;

Echo $ runtime. "seconds ";

?>

Http://www.bkjia.com/PHPjc/742404.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/742404.htmlTechArticleheader ("content-type: text/html; charset = utf-8"); // microtime-returns the current Unix timestamp and microseconds $ oldtime = microtime (true ); echo "the script running time is:"; $ v = 0; for ($ I...

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.