PDA

View Full Version : show page load time


GO ILLINI
06-21-2007, 02:14 AM
<?php

$starttime = time()+microtime();
function PtimerStop() {
global $starttime;
$endtime = time()+microtime();
$totaltime = round($endtime - $starttime,4);
echo 'This page took ' . $totaltime . ' to load.';
}
?>
Some random page stuff and some other php and some
database calls and some other stuff that takes forever
<?php
PtimerStop();
?>Pretty standard... But helpful none-the-less.

-Adam

p@p
07-23-2010, 08:07 PM
It's not worked for me? :(

It could be worked:

<?php
// Get Current Time
$mtime = microtime();
// Split Seconds and Microseconds
$mtime = explode (" ", $mtime);
// Create a single value for start time
$mtime = $mtime[1] + $mtime[0];
// Write Start Time Into A Variable
$tstart = $mtime;

// Get current time (Like above) to get end time
$mtime = microtime();
$mtime = explode (" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
// Store end time in a variable
$tend = $mtime;
// Calculate Difference
$totaltime = ($tend - $tstart);
// Output the result
printf ("This page was generated in %f seconds.", $totaltime);
?>

kbluhm
07-23-2010, 09:30 PM
http://codingforums.com/showthread.php?t=193240#post941425