Time::HiRes

High resolution alarm, sleep, gettimeofday, interval timers
Download

Time::HiRes Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Jarkko Hietaniemi
  • Publisher web site:
  • http://search.cpan.org/~jhi/

Time::HiRes Tags


Time::HiRes Description

High resolution alarm, sleep, gettimeofday, interval timers Time::HiRes is a Perl module that implements an interface to the usleep, nanosleep, ualarm, gettimeofday, and setitimer/getitimer system calls, in other words, high resolution time and timers. See the "EXAMPLES" section below and the test scripts for usage; see your system documentation for the description of the underlying nanosleep or usleep, ualarm, gettimeofday, and setitimer/getitimer calls.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.SYNOPSIS use Time::HiRes qw( usleep ualarm gettimeofday tv_interval nanosleep clock_gettime clock_getres clock_nanosleep clock stat ); usleep ($microseconds); nanosleep ($nanoseconds); ualarm ($microseconds); ualarm ($microseconds, $interval_microseconds); $t0 = ; ($seconds, $microseconds) = gettimeofday; $elapsed = tv_interval ( $t0, ); $elapsed = tv_interval ( $t0, ); $elapsed = tv_interval ( $t0 ); use Time::HiRes qw ( time alarm sleep ); $now_fractions = time; sleep ($floating_seconds); alarm ($floating_seconds); alarm ($floating_seconds, $floating_interval); use Time::HiRes qw( setitimer getitimer ); setitimer ($which, $floating_seconds, $floating_interval ); getitimer ($which); use Time::HiRes qw( clock_gettime clock_getres clock_nanosleep ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF ITIMER_REALPROF ); $realtime = clock_gettime(CLOCK_REALTIME); $resolution = clock_getres(CLOCK_REALTIME); clock_nanosleep(CLOCK_REALTIME, 1.5e9); clock_nanosleep(CLOCK_REALTIME, time()*1e9 + 10e9, TIMER_ABSTIME); my $ticktock = clock(); use Time::HiRes qw( stat ); my @stat = stat("file"); my @stat = stat(FH); Requirements: · Perl


Time::HiRes Related Software