Groovy website page parse time .. thing

ReDuX ReDuX is offline Offline Oct 12th, 2004, 4:23 am |
0
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..
Quick reply to this message  
PHP Syntax
  1. // First you need to include the functions in the header or something
  2.  
  3. // timer start function
  4. function startTimer() {
  5. global $starttime;
  6. $mtime = microtime ();
  7. $mtime = explode (' ', $mtime);
  8. $mtime = $mtime[1] + $mtime[0];
  9. $starttime = $mtime;
  10. }
  11.  
  12. // timer end function
  13. function endTimer() {
  14. global $starttime;
  15. $mtime = microtime ();
  16. $mtime = explode (' ', $mtime);
  17. $mtime = $mtime[1] + $mtime[0];
  18. $endtime = $mtime;
  19. $totaltime = round (($endtime - $starttime), 5);
  20. return $totaltime;
  21. }
  22.  
  23. // now at the start of your header usually immediatly after these
  24. // functions. start the timer with...
  25. startTimer();
  26.  
  27. // all you do now is output it on your page somewhere using this
  28. Page Generation time: <?=endTimer();?>
0
Troy Troy is offline Offline | May 23rd, 2006
Useful, clean, and simple. I like it.
 
0
mohamed badr mohamed badr is offline Offline | Mar 15th, 2008
i think it's not accurate
 
 

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC