usleep & CPU usage

If you’re making a PHP client-server script using a loop to capture events and process data. The CPU usage might be significant. In our test environment, it consumes 50% CPU cycles constantly. A quick and simple fix: add usleep() of about 100-500ms before looping again so it’s still interactive with users yet allow CPU to do something else useful.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *