Is it possible to know the time taken by Apache server to load a PHP page? Is there any log file generated inside Apache server for every page which is running under Apache server?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m going to assume you wish to know how long it took for PHP to generate the page.
When the script starts, since 5.1, there’s an entry in
$_SERVERyou can use, calledREQUEST_TIME. It contains the time when the request was started. At the end of your script you can calculate it like so:Obviously, this is not very accurate and therefore the newer
REQUEST_TIME_FLOATwas introduced in PHP 5.4:For < 5.4 you could use this snippet at the beginning of your script for backwards compatibility:
Update
To let Apache do this for you, you can add the
%Tand/or%Dlog format option, e.g.The
%Toption lets you log the number of seconds taken and%Dlogs the microseconds (since Apache 2).See also: How long does it take to serve a request