note 84249 added to function.time-nanosleep
| From: | b dot andrew at shaw dot ca | Date: | Sat, 05 Jul 2008 04:10:05 +0000 |
| Subject: | note 84249 added to function.time-nanosleep | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-141188@lists.php.net to get a copy of this message | ||
A response to the note below:
Your function is also useless, as the WinNT 32 kernel only functions at a minimum of about 10+ ms
(1,000 us), rendering usleep() useless, because usleep uses the C function which is provided by the
system (in this case, kernel32.dll).
You'll want to use a function that does not rely on the kernel, but rather something made for
precise measurement:
<?php
function usleep_win( $micro_seconds )
{
if ( @function_exists( "socket_create" ) && @function_exists(
"socket_select" ) )
{
$false = NULL;
$socket = array( socket_create( AF_INET, SOCK_RAW, $false ) );
socket_select( $false, $false, $socket, 0, $micro_seconds );
return true;
}
else
{
return false;
}
}
?>
This function will allow to you sleep for a specified microsecond, although I have measured it to be
off by ~5 us.
Again, most of this depends on the hardware in your system. If you _REALLY_ need to be precise to
< 10 us, you shouldn't be using WinNT anyways!
----
Server IP: 216.235.15.211
Probable Submitter: 70.69.75.2
----
Manual Page -- http://www.php.net/manual/en/function.time-nanosleep.php
Edit -- https://master.php.net/note/edit/84249
Del: integrated -- https://master.php.net/note/delete/84249/integrated
Del: useless -- https://master.php.net/note/delete/84249/useless
Del: bad code -- https://master.php.net/note/delete/84249/bad+code
Del: spam -- https://master.php.net/note/delete/84249/spam
Del: non-english -- https://master.php.net/note/delete/84249/non-english
Del: in docs -- https://master.php.net/note/delete/84249/in+docs
Del: other reasons-- https://master.php.net/note/delete/84249
Reject -- https://master.php.net/note/reject/84249
Search -- https://master.php.net/manage/user-notes.php