note 8498 added to gettimeofday

From: Date: Thu, 14 Sep 2000 03:21:35 +0000
Subject: note 8498 added to gettimeofday
Groups: php.notes 
Request: Send a blank email to php-notes+get-4933@lists.php.net to get a copy of this message
Since USLEEP doesn't work under windows, you need to come up with your own fix. gettimeofday() can access useconds on a windows box, so this little function using gettimeofday() will do the trick. function wait($usecs){ $temp=gettimeofday(); $start=(int)$temp["usec"]; while(1){ $temp=gettimeofday(); $stop=(int)$temp["usec"]; if ($stop-$start >= $usecs) break; } } The smallest amount of time it seems to work with is around 200usecs, but if you wait() anything higher than 200usecs it's pretty close. My question is since we can access microseconds on a windows box using this method, why can't we use usleep? :) http://www.php.net/manual/function.gettimeofday.php

« previous php.notes (#4933) next »