jh- has asked for the wisdom of the Perl Monks concerning the following question:
As we all know, Perl's core sleep() only likes integers. There are, however, many places where one would like to sleep for under a second, or for periods other than what can be expressed with normal integers.
There are a few different ways to do it, and the most common ways I've seen are Time::HiRes::sleep($n) or Time::HiRes::usleep($n * 1_000_000) (which, obviously, require Time::HiRes) and select(undef, undef, undef, $n).
Are the different ways of sleeping just a personal preference, or are there some real differences (Memory/CPU usage, accuracy, ...)?
And, finally, what do you use to sleep? Personally, I've always used Time::HiRes::sleep since it's what I used the first time I needed to sleep for a split-second, and the habit just stuck then. :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do you sleep?
by gone2015 (Deacon) on Jan 27, 2009 at 15:36 UTC | |
|
Re: How do you sleep?
by JavaFan (Canon) on Jan 27, 2009 at 13:48 UTC | |
by jh- (Scribe) on Jan 27, 2009 at 17:34 UTC | |
by JavaFan (Canon) on Jan 27, 2009 at 20:04 UTC | |
|
OT: Re: How do you sleep?
by svenXY (Deacon) on Jan 27, 2009 at 13:37 UTC | |
by jh- (Scribe) on Jan 27, 2009 at 13:39 UTC |