Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.