PHP microtime function Record code execution time _php tutorial

Source: Internet
Author: User
Simply say it. Microtime () If a true argument is taken, the return will be a floating-point type. So t1 and T2 get is two floating point number, subtract and get the difference between. Because the number of bits in the floating point is very long, or is not sure, then use a round () to remove the decimal point 3 bits. So our purpose is to reach the ~

The code is as follows Copy Code
$t 1 = microtime (true);
// ... Execute code ...
$t 2 = Microtime (true);
Echo ' time-consuming '. Round ($t 2-$t 1,3). ' Seconds ';
Simply say it. Microtime () If a true argument is taken, the return will be a floating-point type. So t1 and T2 get is two floating point number, subtract and get the difference between. Because the number of bits in the floating point is very long, or is not sure, then use a round () to remove the decimal point 3 bits. So our purpose is to reach the ~

Microtime usage

The Microtime () function returns the current Unix timestamp and the number of microseconds.

Grammar
Microtime (get_as_float) parameter description
Get_as_float if the Get_as_float parameter is given and its value is equivalent to TRUE, the function returns a floating-point number.


http://www.bkjia.com/PHPjc/445305.html www.bkjia.com true http://www.bkjia.com/PHPjc/445305.html techarticle just say it. Microtime () If you have a true argument, the return will be a floating-point type. So t1 and T2 get two floating-point numbers, subtract the difference between them. Because floating point ...

  • 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.