Home > Backend Development > PHP Tutorial > Speed ​​optimization - PHP program execution efficiency problem

Speed ​​optimization - PHP program execution efficiency problem

WBOY
Release: 2016-08-18 09:15:32
Original
975 people have browsed it

One of the methods in my controller has a long piece of code logic, I won’t post the specific code. The main thing I want to ask you is how can I know how long it takes each time I execute this method and what the execution speed is!

Reply content:

One of the methods in my controller has a long piece of code logic, I won’t post the specific code. The main thing I want to ask you is how can I know how long it takes each time I execute this method and what the execution speed is!

Thank you for the invitation. In fact, it is very simple. You only need to output two times at the entrance and end of your method. Subtract the start time from the end time to get the program execution time! Right? Of course, you need to pay special attention to it. You need to use microseconds for better comparison. phpsubtle reference microtime

You can use this method at the beginning and end, just find the difference

<code>function microtime_float(){
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}</code>
Copy after login
Related labels:
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