Php microtime function Record code execution time _ PHP Tutorial

Source: Internet
Author: User
The microtime function in php records the code execution time. To put it simply. microtime () if it contains a true parameter, a floating point type is returned. in this way, t1 and t2 get two floating point numbers, and the difference is obtained after subtraction. for a brief description of floating point. microtime () if it contains a true parameter, a floating point type is returned. in this way, t1 and t2 get two floating point numbers, and the difference is obtained after subtraction. because the number of floating point digits is very long or uncertain, we can use a round () to retrieve the three digits after the decimal point. in this way, our goal is achieved ~

The code is as follows:
$ T1 = microtime (true );
//... Execute the code...
$ T2 = microtime (true );
Echo 'elapsed Time'. round ($ t2-$ t1, 3). 'second ';
To put it simply. microtime () if it contains a true parameter, a floating point type is returned. in this way, t1 and t2 get two floating point numbers, and the difference is obtained after subtraction. because the number of floating point digits is very long or uncertain, we can use a round () to retrieve the three digits after the decimal point. in this way, our goal is achieved ~

Microtime usage

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

Syntax
Microtime (get_as_float) parameter description
If the get_as_float parameter is given and its value is equivalent to TRUE, this function returns a floating point number.


Period. microtime () if it has a true parameter, the returned value will be a floating point type. in this way, t1 and t2 get two floating point numbers, and the difference between them is obtained after subtraction. because of the 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.