Home  >  Article  >  Backend Development  >  Example of php calculating the execution time of the current page

Example of php calculating the execution time of the current page

WBOY
WBOYOriginal
2016-07-25 09:07:361028browse
  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.



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