View Full Version : calculating the load time of a web page
davehaz
02-20-2006, 06:23 PM
howdy,
does anybody know how to calculate the load time of a webpage using php?
thanks.
alexpayne
02-20-2006, 06:57 PM
you could record in a table the load time everytime someone requests it, and then use an average.
davehaz
02-20-2006, 07:02 PM
exactly what I wanted to do, but how do you get the load times to average?
marek_mar
02-20-2006, 07:07 PM
There is an equation for the average.
Avarage = Sum of all values / Number of values.
Brandoe85
02-20-2006, 07:09 PM
There should be a few examples here (http://www.google.com/search?hl=en&q=php+load+time&btnG=Google+Search)
davehaz
02-20-2006, 07:48 PM
actually Marek_Mar it would be
Average = Sum of all values / Number of values
thanks.
felgall
02-20-2006, 08:31 PM
Of course there is no way to tell if the person waited for the whole page to load or whether they loaded the page without images so any stats you get will be fairly meaningless.
StupidRalph
02-20-2006, 09:12 PM
Do you mean like how google shows you how long it took to conduct a search? Or how on some sites shows you how long it took to long and how many different queries were used? You might want to start looking at this function. Also check the comments below. Microtime (http://www.php.net/microtime)
/*
*@author steve gricci
*@access public
*@skill beginner
*@site www.deepcode.net
*/
//put at begining of file
function utime (){
$time = explode( " ", microtime());
$usec = (double)$time[0];
$sec = (double)$time[1];
return $sec + $usec;
}
$start = utime();
//put at end of page before body and html tags
$end = utime(); $run = $end - $start; echo "Page expelled in " . substr($run, 0, 5) . " secs.";
//Nothing after this
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.