note 41405 deleted from function.microtime by aidan

From: Date: Tue, 28 Sep 2004 12:08:39 +0000
Subject: note 41405 deleted from function.microtime by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77484@lists.php.net to get a copy of this message
Note Submitter: mark dot young at vdhinc dot com ---- Yet another quick&easy code timing function (and the getmicrotime() function from the earlier example): $STARTTIME = getmicrotime(); $LASTTIME = $STARTTIME; $TIMESTAMPCOUNT=0; function PrintTimestamp() { global $STARTTIME, $LASTTIME, $TIMESTAMPCOUNT; $now = getmicrotime(); echo "\n\n<!-- [TIME] "; echo "Elapsed: ".number_format($now-$STARTTIME,4); echo " Delta: ".number_format($now-$LASTTIME, 6); echo " Now: ".$now; echo " Instance: ".$TIMESTAMPCOUNT++; echo " -->\n\n"; $LASTTIME = $now; } Call that function somewhere in your code, and it'll output this stuff: <!-- [TIME] Elapsed:7.0750 Delta: 1.747464 Now: 1081451042.46 Instance: 1 --> Elapsed - Time since the code began (assuming those globals are at the top of your code) Delta - Elapsed time since the last call to PrintTimestamp() Now - System epoch time Instance - increments by one with each call, useful for loop timing.

« previous php.notes (#77484) next »