Home>Article>Backend Development> How to calculate program running time in php

How to calculate program running time in php

autoload
autoload Original
2021-04-01 14:21:06 5494browse

How to calculate program running time in php

1. Functions used

a. Use the functionmicrotime ()

microtime ( bool $get_as_float = ? ) : mixed
  • $get_as_floatwhich can be omitted when set toTRUEWhen , it is specified that the function should return a floating point number, otherwise it returns a string. Default is FALSE.

  • Return value: Default return string , wheresecis the sinceUnixepoch (0:00:00 January 1, 1970 GMT) The number of seconds since,microsecis the microsecond part. If the argument is set toTRUE, returns a floating point number representing the current time in seconds since theUnixepoch, accurate to microseconds.

b. Use the functionexplode()

explode(separator,string,limit)
  • separator to specify where to split characters string.

  • string The string to be split.

  • limit specifies the number of array elements returned (optional)

2. The code is as follows :

3. Output:

0.58607300 1617257726本网页执行耗时:0.017 秒。1617257726

PS: For the sake of neatness of the program, we can use this code This function can also be achieved by writing it as a class, introducing it when used, instantiating the class before the program starts, and calling a method at the end.

Recommendation:2021 PHP interview questions summary (collection)》《php video tutorial

The above is the detailed content of How to calculate program running time in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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