note 53810 added to function.microtime

From: Date: Tue, 14 Jun 2005 05:23:10 +0000
Subject: note 53810 added to function.microtime
Groups: php.notes 
Request: Send a blank email to php-notes+get-90389@lists.php.net to get a copy of this message
Hmm...perhaps their is some speed loss to unluckypixie's method...anyone want to check this out? On a side note, personally, the way I'm doing it for cross-compatibility between PHP4 and PHP5 is by simply doing a version compare. I mean, compiled code is always faster than interpreted. .::My method::. <?php /* * Copyright 2005, Wesley Spikes. * nofulfillment@numbinside.net * http://nothingcanfulfill.numbinside.net * * Freely distributable. My only request is that you * credit me in the source code (by not removing this * copyright notice) and email me telling me that you're * using it (I'd love to know that my code is being put to * good use)! * As usual, there are no warranties, express or implied * alike, as to ...blah, blah, blah. (Where's the vodka... * legal shit drives one insane!) * * INFO: a new twist on the getmicrotime() function. if * we're using a version of php that supports the new * get_as_float parameter (PHP>5.0.0) then use the * newly supported paramater as built-in functions are * generally faster. otherwise, use the old method of * splitting the two parts and adding them togeather. * * As a bit of advertising bull...I'm currently in the * process of creating a page on my new website for * code sniplets like this (that would make number * 1,000,001 on the internet). */ if (version_compare("5.0.0",phpversion(),"<=")==1) { function getmicrotime() { return microtime(1); } } else { function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } } ?> The above code will create a function which returns a float containing the current ``microtime''. Syntax as follows: float getmicrotime( ) -Wes ---- Manual Page -- http://www.php.net/manual/en/function.microtime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+53810 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53810&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53810&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53810&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53810&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53810&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+53810&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90389) next »