Example of php calculating the execution time of the current page

WBOY
Release: 2016-07-25 09:07:36
Original
994 people have browsed it
  1. //do something
  2. sleep(3);
  3. //do something
  4. $running_time = time() - $_SERVER['REQUEST_TIME'];
  5. echo 'Page running time:', $running_time,' seconds';
  6. ?>
Copy the code

Execution example output is as follows: Page running time: 3 seconds annotation: $_SERVER['REQUEST_TIME'] is PHP's built-in timestamp when the current page starts running. When the current page ends, time() - $_SERVER['REQUEST_TIME'] will get the time (seconds) when the current page runs.



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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!