I just had a look at the docs on sleep().
Where would you use this function?
Is it there to give the CPU a break in an expensive function?
Any common pitfalls?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One place where it finds use is to create a delay.
Lets say you’ve built a crawler that uses
curl/file_get_contentsto get remote pages. Now you don’t want to bombard the remote server with too many requests in short time. So you introduce a delay between consecutive requests.sleeptakes the argument in seconds, its friendusleeptakes arguments in microseconds and is more suitable in some cases.