If you want a nice object oriented solution that's easy to use over and over again which does pretty much the same thing, give this class a whirl.On top use this: <?php $mtime = explode(" ",microtime()); $starttime = $mtime[1] + $mtime[0]; ?>
On the end use this: <?php $mtime = explode(" ",microtime()); $endtime = $mtime[1] + $mtime[0]; echo "\n\n\n<hr><b>".round($endtime-$starttime,3)." sec</b>"; ?>
class page_gen {
//
// PRIVATE - DO NOT MODIFY
//
var $cls_start_time;
var $cls_stop_time;
var $cls_gen_time;
//
// FIGURE OUT THE TIME AT THE BEGINNING OF THE PAGE
//
function start() {
$microstart = explode(' ',microtime());
$this->cls_start_time = $microstart[0] + $microstart[1];
}
//
// FIGURE OUT THE TIME AT THE END OF THE PAGE
//
function stop() {
$microstop = explode(' ',microtime());
$this->cls_stop_time = $microstop[0] + $microstop[1];
}
//
// CALCULATE THE DIFFERENCE BETWEEN THE BEGINNNG AND THE END AND COLOR CODE THE RESULT
//
function gen() {
$this->cls_gen_time = round($this->cls_stop_time - $this->cls_start_time,5);
return $this->cls_gen_time;
}
}
then, on the page you want to time, just put at the top:
require('class.pagegen.php') // OR WHATEVE YOU NAMED IT $pagegen = new page_gen(); $pagegen->start(); // START TIMING
then at the end... $pagegen->stop(); // STOP TIMING $pagegen->gen(); // RETURN GENERATION TIME
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php