Home  >  Article  >  Backend Development  >  PHP simple calculation of page loading time

PHP simple calculation of page loading time

*文
*文Original
2017-12-27 10:58:521962browse

How does php calculate page loading time? This article mainly introduces PHP's simple method of calculating page loading time, involving PHP's calculation skills for page loading time. I hope to be helpful.

The example in this article describes how to simply calculate the page loading time in PHP. Share it with everyone for your reference. The specific implementation method is as follows:

Simply put the start time at the head of the page and the end time at the end of the page to calculate the page loading time

$start = time();
// put a long operation in here
sleep(2);
$diff = time() - $start;
print "This page needed $diff seconds to load :-)";
// if you want a more exact value, you could use the 
// microtime function

Related recommendations:

PHP solves session file blocking

The use of php pseudo-reloading

PHP improves performance through opcache

The above is the detailed content of PHP simple calculation of page loading time. 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