Home > Backend Development > PHP Tutorial > PHP records code execution time (implementation code)_PHP tutorial

PHP records code execution time (implementation code)_PHP tutorial

WBOY
Release: 2016-07-21 15:01:36
Original
799 people have browsed it

Copy code The code is as follows:

$t1 = microtime(true);
//... Execute the code...
$t2 = microtime(true);
echo 'time-consuming'.round($t2-$t1,3).'seconds';

Say briefly . If microtime() takes a true parameter, it will return a floating point type. In this way, t1 and t2 will get two floating point numbers, and the difference will be obtained after subtracting them. Since the number of floating point digits is very small, long, or uncertain, so we use round() to take out 3 digits after the decimal point. In this way, our goal is achieved~

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327993.htmlTechArticleCopy the code The code is as follows: $t1 = microtime(true); // ... execute the code... $ t2 = microtime(true); echo 'time-consuming'.round($t2-$t1,3).'seconds'; Let's talk briefly. microtime() If you bring a tru...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template