note 49965 added to function.gettimeofday

From: Date: Mon, 14 Feb 2005 02:26:13 +0000
Subject: note 49965 added to function.gettimeofday
Groups: php.notes 
Request: Send a blank email to php-notes+get-84977@lists.php.net to get a copy of this message
A small improvement on getTimer. Using vsprintf instead of sprintf there is no need to assign the array: <?php function utime() { return (float) (vsprintf('%d.%06d', gettimeofday())); } ?> In a test on my machine getTimer took 0.037519 seconds to run through 1000 iterations versus 0.027912 seconds for utime. In total, utime runs about 25% quicker. The use is negligible in an actual benchmarking scenario, but this could provide a slightly more accurate estimate. Of course the time it takes to run the function could always be stored at the start and subtracted from your total value each time it is run. ---- Manual Page -- http://www.php.net/manual/en/function.gettimeofday.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49965 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49965&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49965&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49965&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49965&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49965&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49965&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84977) next »