On 8/15/07, Dr.Ruud <[EMAIL PROTECTED]> wrote: > "Chas Owens" schreef: > > > A one second sleep is common, but you can sleep for less than a second > > with usleep from the Time::HiRes* module if this is too slow for your > > purposes. > > AFAIK, a "sleep 1" could take anything between 0 and 2 seconds. See also > select(). snip
Well, technically, a "sleep 1" could take over an hour of wall time; however, the request is for one second (some old machines used the next second which was often less than one full second) and it is usually one second (or so near as to not matter). With no load on my system I get skew of less than .01 seconds per iteration of perl -MTime::HiRes -le ' while (1) { print join ".", Time::HiRes::gettimeofday; sleep 1; } ' and I believe most of that is the is the code running between the calls to sleep. I get the same skew with a pure cpu load (2 busy waits for my 2 cpu system). Even the number (I used 3000) of greedy processes doesn't change the skew even though I lose my mouse pointer in X. from perldoc -f sleep On some older systems, it may sleep up to a full second less than what you requested, depending on how it counts seconds. Most modern systems always sleep the full amount. They may appear to sleep longer than that, however, because your process might not be scheduled right away in a busy multitasking sys‐ tem. For delays of finer granularity than one second, you may use Perl's "syscall" interface to access setitimer(2) if your sys‐ tem supports it, or else see "select" above. The Time::HiRes module (from CPAN, and starting from Perl 5.8 part of the stan‐ dard distribution) may also help. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/