[PHP] How to reduce CPU usage in a cycle? [ag]

2003-12-11 Thread TauAlex
Hello! I'm having a problem with my php script on my linux web server. In that script there is a cycle with some math calculations (about ~30 steps), the execution time is less 1 second, but the script loads the server CPU up to 90%... I've optimized script already to the minimum math function,

Re: [PHP] How to reduce CPU usage in a cycle? [ag]

2003-12-11 Thread Brent Baisley
Personally, I wouldn't worry about it unless it is actually interfering with other processes. The OS will give any process or thread 100% of the CPU if there is nothing else that needs the CPU. What does you context switching numbers look like? If there is a lot of context switching, then your

Re: [PHP] How to reduce CPU usage in a cycle? [ag]

2003-12-11 Thread Jas
Well have you tried to define one function to include the for all variables that require mt_rand()? Jas Brent Baisley wrote: Personally, I wouldn't worry about it unless it is actually interfering with other processes. The OS will give any process or thread 100% of the CPU if there is nothing

Re: [PHP] How to reduce CPU usage in a cycle? [ag]

2003-12-11 Thread Jas
ex. ?php function rand($attack,$skills,$damage,$armor) { $do = array($attack,$skills,$damage,$armor); finish=false while (!finish) { $do = mt_rand(mktime(microtime(1,100)); } while($do = list($attack,$skills,$damage,$armor)) { calculate total damage for opponent } } ? I read that the use of