Time::HiRes 1.9719
Time::HiRes 1.9719 Ranking & Summary
Time::HiRes 1.9719 description
Time:HiRes 1.9719 is one of the most marvelous tools which implements a Perl interface to the usleep, nanosleep, ualarm, gettimeofday, and setitimer/getitimer system calls, in other words, high resolution time and timers.
If your system lacks gettimeofday or an emulation of it you don't get gettimeofday or the one-argument form of tv_interval. If your system lacks all of nanosleep, usleep, select, and poll, you don't get Time:HiRes:usleep, Time:HiRes:nanosleep(), or Time:HiRes:sleep. If your system lacks both ualarm and setitimer you don't get Time:HiRes:ualarm or Time:HiRes:alarm.
If you try to import an unimplemented function in the use statement it will fail at compile time.
If your subsecond sleeping is implemented with nanosleep() instead of usleep(), you can mix subsecond sleeping with signals since nanosleep() does not use signals. This, however, is not portable, and you should first check for the truth value of &Time:HiRes:d_nanosleep to see whether you have nanosleep, and then carefully read your nanosleep C API documentation for any peculiarities.
If you are using nanosleep for something else than mixing sleeping with signals, give some thought to whether Perl is the tool you should be using for work requiring nanosecond accuracies.
Remember that unless you are working on a hard realtime system, any clocks and timers will be imprecise, especially so if you are working in a pre-emptive multiuser system. Understand the difference between wallclock time and process time (in UNIX-like systems the sum of user and system times). Any attempt to sleep for X seconds will most probably end up sleeping more than that, but don't be surpised if you end up sleeping slightly less.
Major Features:
- gettimeofday
- In array context returns a two-element array with the seconds and microseconds since the epoch. In scalar context returns floating seconds like Time:HiRes:time.
- usleep
- Sleeps for the number of microseconds (millionths of a second) specified. Returns the number of microseconds actually slept. Can sleep for more than one second, unlike the usleep system call. Can also sleep for zero seconds, which often works like a thread yield. See also Time:HiRes:usleep, Time:HiRes:sleep, and Time:HiRes:clock_nanosleep.
- Do not expect usleep to be exact down to one microsecond.
- nanosleep
- Sleeps for the number of nanoseconds specified. Returns the number of nanoseconds actually slept (accurate only to microseconds, the nearest thousand of them). Can sleep for more than one second. Can also sleep for zero seconds, which often works like a thread yield.
- Do not expect nanosleep to be exact down to one nanosecond. Getting even accuracy of one thousand nanoseconds is good.
- Sleeps for the number of nanoseconds specified. Returns the number of nanoseconds actually slept (accurate only to microseconds, the nearest thousand of them). Can sleep for more than one second. Can also sleep for zero seconds, which often works like a thread yield.
- ualarm
- Issues a ualarm call; the $interval_useconds is optional and will be zero if unspecified, resulting in alarm-like behaviour.
- Returns the remaining time in the alarm in microseconds, or undef if an error occurred.
- ualarm(0) will cancel an outstanding ualarm
- Note that the interaction between alarms and sleeps is unspecified.
- tv_interval
- Returns the floating seconds between the two times, which should have been returned by gettimeofday. If the second argument is omitted, then the current time is used.
- time
- Returns a floating seconds since the epoch. This function can be imported, resulting in a nice drop-in replacement for the time provided with core Perl
Time::HiRes 1.9719 Screenshot
Time::HiRes 1.9719 Keywords
Bookmark Time::HiRes 1.9719
Time::HiRes 1.9719 Copyright
Want to place your software product here?
Please contact us for consideration.
Contact WareSeeker.com