Jump to content

Help me please


oceans

Recommended Posts

Dear Friend,

 

I wish to insert “usleep()” in a while loop.

 

While(not right)

{

Usleep(100);

}

 

Ok it is right, do something, bla bla bla …

 

I was advised usleep() will soak up server resource. How can I improve or use an alternative.

 

I admit I have done such operation in VB, I had such problem, and I later developed my own sleep function call which used almost no resource.

 

But I am not sure if usleep() is efficient, have you experienced this? Any comment.

Link to comment
https://forums.phpfreaks.com/topic/51771-help-me-please/
Share on other sites

Interesting!

 

I have just test it out on my system. 

 

usleep(50000000); // sleep for 50 seconds

 

and watch the system resource and performance.

 

I found no resource being used.  CPU idle is 100%.  Memory used does not change.

 

I guest it is safe-to-use function.

 

os: xp pro

php version: 5

 

Link to comment
https://forums.phpfreaks.com/topic/51771-help-me-please/#findComment-255056
Share on other sites

I remembered one time when I tried to test the server time out value, I think it was file upload time out.  Instead of dumping out a big upload file, I set the script to wait 15.1 minutes (upload time out is set at 15). 

 

But you right, I never encounter a situation where I must delay the script execution.

Link to comment
https://forums.phpfreaks.com/topic/51771-help-me-please/#findComment-255060
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.