Performance of while(true) loop
| From: | APseudoUtopia | Date: | Thu, 10 Sep 2009 02:32:27 +0000 |
| Subject: | Performance of while(true) loop | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-297848@lists.php.net to get a copy of this message | ||
Hey list,
I have a php cli script that listens on a UDP socket and, when data is
sent to the socket, the script inserts it into a database. I'm using
the real BSD socket functions, not fsock.
The script runs socket_create(), then socket_bind(). Then it starts a
while(TRUE) loop. Within the loop, it runs socket_recvfrom(). I have
it running 24/7 inside a screen window.
I'm curious as to the cpu/memory/etc usage of a while(true) loop. The
top command shows that the process is in the sbwait state (the OS is
FreeBSD). I'm contemplating adding a usleep or even a sleep inside to
loop. Would this be beneficial? I'm not too sure of how the internals
of PHP work in terms of loops and such.
Thanks.