note 41405 added to function.microtime

From: Date: Thu, 08 Apr 2004 19:13:26 +0000
Subject: note 41405 added to function.microtime
Groups: php.notes 
Request: Send a blank email to php-notes+get-67837@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.microtime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41405 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41405&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41405&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67837) next »