Re: microtime() Accuracy

From: Date: Wed, 05 Jul 2000 21:45:07 +0000
Subject: Re: microtime() Accuracy
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-5080@lists.php.net to get a copy of this message
On Wed, 5 Jul 2000, Stephen J. Taranto wrote: > I have a question about the accuracy of the microtime() function. Given the > following code --- > > $st = split(" ", microtime()); > // A bunch of PHP code. > $et = split(" ", microtime()); > $ct = ($et[0] + $et[1]) - ($st[0] + $st[1]); > echo "<P>Clock: <B>$ct</B><BR>\n"; > > I'll regularly get $ct equal to .00172234121 and the like. > > My question is just how accurate is that number? I really don't care about > anything past the thousandths place. Can I assume that it is at least > accurate to that point? I'd imagine this is highly dependent on the > OS/hardware. Anyone have a rule of thumb I can use for determining how > accurate this number is given a certain OS/hardware combinatio? I'm > primarily interesting in Solaris 7/Sparc, Linux/Intel and Win2k/Intel. > (BTW, PHP 4.0.0 no Zend optimization). Not only that, it'll vary on the load at that particular moment, memory, and all sorts of other variables. I'd suggest making your script track an average, and running it until you're satisfied that the average has stabalized at a point. I can't imagine there being a reliable basis for comparison when you're talking about microtime(), really. Anyone else? :) Matt

« previous php.general (#5080) next »