Groovy website page parse time .. thing

ReDuX 0 Tallied Votes 165 Views Share

Well like my previous snippet but completing the collection i suppose, this snippet counts how long it takes to parse the page and displays it somewhere..

// First you need to include the functions in the header or something

// timer start function
function startTimer() { 
   global $starttime; 
   $mtime = microtime (); 
   $mtime = explode (' ', $mtime); 
   $mtime = $mtime[1] + $mtime[0]; 
   $starttime = $mtime; 
} 

// timer end function
function endTimer() { 
   global $starttime; 
   $mtime = microtime (); 
   $mtime = explode (' ', $mtime); 
   $mtime = $mtime[1] + $mtime[0]; 
   $endtime = $mtime; 
   $totaltime = round (($endtime - $starttime), 5); 
   return $totaltime; 
} 

// now at the start of your header usually immediatly after these 
// functions. start the timer with...
startTimer();

// all you do now is output it on your page somewhere using this
Page Generation time: <?=endTimer();?>
Troy 35 Posting Whiz

Useful, clean, and simple. I like it.

mohamed badr 0 Newbie Poster

i think it's not accurate

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.