Does sleep time count for execution time limit?

Spoiler: Under Linux, sleeping time is ignored, but under Windows, it counts as execution time.

You should try it, just have a script that sleeps for more than your maximum execution time. Spoiler: Under Linux, sleeping time is ignored, but under Windows, it counts as execution time.

Thanks, I have UNIX so it doesn't count. – Marco W. Apr 11 '09 at 23:29 1 You can actually accept his answer, and make a service for the community.

– Itay Moav Apr 11 '09 at 23:38.

It only affects script time not system calls like sleep(). There is apparently a bug where on Windows sleep() is included. Max execution time is about real-time, not CPU time or anything like that.

You can change it however: max_execution_time directive in your php.ini. This is a global setting; Using ini_set() with the above directive. This will change it only for the currently executing script only for that execution; set_time_limit(): also a local change.As for the difference between the last two, I believe max_execution_time is a fixed quantity.

Running: ini_set('max_execution_time', 60); will limit to the script to 60 seconds. If after 20 seconds you call: set_time_limit(60); the script will now be limited to 20 + 60 = 80 seconds.

– cletus Apr 11 '09 at 23:20 Probably because you changed your answer to be correct after the downvote. – Samuel Apr 11 '09 at 23:21 There's no edited time at the bottom, how could he have changed it? – Calvin Apr 11 '09 at 23:30 I don't know why it was downvoted.

I am the questioner and you answered my question well. Thanks! – Marco W.

Apr 11 '09 at 23:33 @Calvin: In case you haven't noticed, they changed it a few weeks (or days) to give a much larger grace period for no edit history. – Samuel Apr 11 '09 at 23:59.

From the PHP sleep() page, there's this user-contributed note: Note: The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), the sleep() function, database queries, etc. Is not included when determining the maximum time that the script has been running.

Just to add, this behavior is exhibited on *nix only. On windows set_time_limit() wins every time. – Crescent Fresh Apr 11 '09 at 23:20.

Others have already covered the basics of sleep() and PHP script execution time limit, but you should also be aware of another risk when using really long sleep periods. Usually, when a browser sends a request to a server and does not receive any data from the server, the connection can time out. This time limit depends on the browser's configurations, but I've read that IE7 has a default value of just 30 seconds, while Firefox has a default value of 300 seconds--you can check your own configuration in Firefox by going to about:config and filtering for network.http.

Keep-alive. Timeout (the time limit is specified in seconds). Edit: I had the units for network.http.

Keep-alive. Timeout and browser.urlbar.search. Timeout mixed up.It is indeed in seconds, not tenths of a second.

Thanks, I didn't know that before. I think the limit must be specified in 1/1ths of a second because the value in about:config is 30. ;) – Marco W.

Apr 11 '09 at 23:58 Ah, you're right. It is in seconds. But the default ought to be 300 seconds, not 30, so perhaps your settings were changed by a browser extension.

– Calvin Apr 12 '09 at 0:10.

A) Yes, it counts toward the time limit (so sleep(31) will trigger an error) b) It does the opposite of costing CPU performance - it lets other applications use the CPU (when an application sleeps, the CPU usage of that application will be near 0%). Aside from taking time away from the user, I can't really think of any risks of using this.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions