How to calculate program running time in php

autoload
Release: 2023-03-09 09:40:02
Original
5473 people have browsed it

How to calculate program running time in php

1. Functions used

a. Use the functionmicrotime ()

microtime ( bool $get_as_float = ? ) : mixed
Copy after login
  • $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)
Copy after login
  • 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 :

Copy after login

3. Output:

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

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!

Related labels:
php
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!