note 105429 added to function.usleep

From: Date: Wed, 17 Aug 2011 08:26:49 +0000
Subject: note 105429 added to function.usleep
Groups: php.notes 
Request: Send a blank email to php-notes+get-182523@lists.php.net to get a copy of this message
There is a very strange behaviour, which I experience under Win7 64-bit, PHP 5.3.6: The very first call of usleep of the PHP script will (sometimes) wait significantly shorter than it actually should. <?php usleep(1); // Dodge the strange behaviour for ($i = 0; $i < 20; $i++) // Reapet 20 times { $start_time = microtime(true); // save start time usleep(10000); // wait theoretical 10ms $end_time = microtime(true); // save end time $wait_time[] = ($end_time - $start_time) * 1000; // calc the difference (which should be around 10ms) } var_dump($wait_time); // dump all the results ?> If you leave away the first line (usleep(1);) you will get varying values for $wait_time[0] between 1 and 13, whilst all the other values are around 15 (for me). ---- Server IP: 69.147.83.197 Probable Submitter: 46.14.226.201 ---- Manual Page -- http://www.php.net/manual/en/function.usleep.php Edit -- https://master.php.net/note/edit/105429 Del: integrated -- https://master.php.net/note/delete/105429/integrated Del: useless -- https://master.php.net/note/delete/105429/useless Del: bad code -- https://master.php.net/note/delete/105429/bad+code Del: spam -- https://master.php.net/note/delete/105429/spam Del: non-english -- https://master.php.net/note/delete/105429/non-english Del: in docs -- https://master.php.net/note/delete/105429/in+docs Del: other reasons-- https://master.php.net/note/delete/105429 Reject -- https://master.php.net/note/reject/105429 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182523) next »