PHP Processor Usage
Moderator: General Moderators
PHP Processor Usage
For my customer, I have some intensive reports that culls through data based on a date range. I noticed that if I pick a large date range (say 1 month) PHP.exe spikes the processor to 100% for several seconds. I realize that the time that the processor is spiked is due to the report requirement and the multi-day range. But that fact that the processor spikes to 100% concerns me. In multi-threaded C++, you add a sleep to allow the thread to give back a time slice to the processor. Is there a way with PHP to do a sleep to effectively give back time to the processor? Is there anyway to force PHP to only use some max percentage of the processor? Any suggestions or ideas?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
I'd suggest optimizing your code first. The [php_man]sleep[/php_man] function in php may give it's time back to the machine, but since its time units are in seconds, that's a lot of time tossed back. There is [php_man]usleep()[/php_man] as well, but does not work on windows machines until php5... if that matters.
if you are using linux...
Code: Select all
user@host: man ulimitThanks guys. Unfortunately I'm using Windows (customer requirement). Also, this is a legacy system where the database design is so poor that optimizing my code has only gone so far. I know that a redesign would significantly help the total report time. I'll look at usleep(), thanks alot for the help.