note 54954 deleted from function.microtime by tularis

From: Date: Sun, 22 Jun 2008 12:14:22 +0000
Subject: note 54954 deleted from function.microtime by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-140700@lists.php.net to get a copy of this message
Note Submitter: DEBO Jurgen <jurgen AT person DOT be> ---- To generate parsing time of a HTML page: This works with a STATIC var. So You do not need to store starttime at all. Usage : Call this twice on top of Your template, and before </body> function stopwatch(){ static $mt_previous = 0; list($usec, $sec) = explode(" ",microtime()); $mt_current = (float)$usec + (float)$sec; if (!$mt_previous) { $mt_previous = $mt_current; return ""; } else { $mt_diff = ($mt_current - $mt_previous); $mt_previous = $mt_current; return sprintf('%.16f',$mt_diff); } }

« previous php.notes (#140700) next »