Saturday, June 11, 2016

How to measure the speed of a website using php?


Simplest way to measure any webpage response time is use Firefox or Chrome developer menu options which display the total access time to the server.

However if you need to do this in PHP then it be done by simple method like below.

 $startTime = microtime(true);
register_shutdown_function
('measureTime');

function measureTime(){
global $startTime;
$execTime
= microtime(true)-$startTime;
echo
"Script execution time: $execTime seconds.";
}