This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Time-HiRes version bump
[perl5.git] / dist / Time-HiRes / HiRes.pm
1 package Time::HiRes;
2
3 { use 5.006; }
4 use strict;
5
6 require Exporter;
7 require DynaLoader;
8
9 our @ISA = qw(Exporter DynaLoader);
10
11 our @EXPORT = qw( );
12 our @EXPORT_OK = qw (usleep sleep ualarm alarm gettimeofday time tv_interval
13                  getitimer setitimer nanosleep clock_gettime clock_getres
14                  clock clock_nanosleep
15                  CLOCK_BOOTTIME CLOCK_HIGHRES
16                  CLOCK_MONOTONIC CLOCK_MONOTONIC_COARSE
17                  CLOCK_MONOTONIC_PRECISE CLOCK_MONOTONIC_RAW
18                  CLOCK_PROCESS_CPUTIME_ID
19                  CLOCK_REALTIME CLOCK_REALTIME_COARSE
20                  CLOCK_REALTIME_FAST CLOCK_REALTIME_PRECISE
21                  CLOCK_SECOND CLOCK_SOFTTIME CLOCK_THREAD_CPUTIME_ID
22                  CLOCK_TIMEOFDAY CLOCKS_PER_SEC
23                  ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF ITIMER_REALPROF
24                  TIMER_ABSTIME
25                  d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer
26                  d_nanosleep d_clock_gettime d_clock_getres
27                  d_clock d_clock_nanosleep
28                  stat lstat
29                 );
30
31 our $VERSION = '1.9733';
32 our $XS_VERSION = $VERSION;
33 $VERSION = eval $VERSION;
34
35 our $AUTOLOAD;
36 sub AUTOLOAD {
37     my $constname;
38     ($constname = $AUTOLOAD) =~ s/.*:://;
39     # print "AUTOLOAD: constname = $constname ($AUTOLOAD)\n";
40     die "&Time::HiRes::constant not defined" if $constname eq 'constant';
41     my ($error, $val) = constant($constname);
42     # print "AUTOLOAD: error = $error, val = $val\n";
43     if ($error) {
44         my (undef,$file,$line) = caller;
45         die "$error at $file line $line.\n";
46     }
47     {
48         no strict 'refs';
49         *$AUTOLOAD = sub { $val };
50     }
51     goto &$AUTOLOAD;
52 }
53
54 sub import {
55     my $this = shift;
56     for my $i (@_) {
57         if (($i eq 'clock_getres'    && !&d_clock_getres)    ||
58             ($i eq 'clock_gettime'   && !&d_clock_gettime)   ||
59             ($i eq 'clock_nanosleep' && !&d_clock_nanosleep) ||
60             ($i eq 'clock'           && !&d_clock)           ||
61             ($i eq 'nanosleep'       && !&d_nanosleep)       ||
62             ($i eq 'usleep'          && !&d_usleep)          ||
63             ($i eq 'ualarm'          && !&d_ualarm)) {
64             require Carp;
65             Carp::croak("Time::HiRes::$i(): unimplemented in this platform");
66         }
67     }
68     Time::HiRes->export_to_level(1, $this, @_);
69 }
70
71 bootstrap Time::HiRes;
72
73 # Preloaded methods go here.
74
75 sub tv_interval {
76     # probably could have been done in C
77     my ($a, $b) = @_;
78     $b = [gettimeofday()] unless defined($b);
79     (${$b}[0] - ${$a}[0]) + ((${$b}[1] - ${$a}[1]) / 1_000_000);
80 }
81
82 # Autoload methods go after =cut, and are processed by the autosplit program.
83
84 1;
85 __END__
86
87 =head1 NAME
88
89 Time::HiRes - High resolution alarm, sleep, gettimeofday, interval timers
90
91 =head1 SYNOPSIS
92
93   use Time::HiRes qw( usleep ualarm gettimeofday tv_interval nanosleep
94                       clock_gettime clock_getres clock_nanosleep clock
95                       stat lstat );
96
97   usleep ($microseconds);
98   nanosleep ($nanoseconds);
99
100   ualarm ($microseconds);
101   ualarm ($microseconds, $interval_microseconds);
102
103   $t0 = [gettimeofday];
104   ($seconds, $microseconds) = gettimeofday;
105
106   $elapsed = tv_interval ( $t0, [$seconds, $microseconds]);
107   $elapsed = tv_interval ( $t0, [gettimeofday]);
108   $elapsed = tv_interval ( $t0 );
109
110   use Time::HiRes qw ( time alarm sleep );
111
112   $now_fractions = time;
113   sleep ($floating_seconds);
114   alarm ($floating_seconds);
115   alarm ($floating_seconds, $floating_interval);
116
117   use Time::HiRes qw( setitimer getitimer );
118
119   setitimer ($which, $floating_seconds, $floating_interval );
120   getitimer ($which);
121
122   use Time::HiRes qw( clock_gettime clock_getres clock_nanosleep
123                       ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF
124                       ITIMER_REALPROF );
125
126   $realtime   = clock_gettime(CLOCK_REALTIME);
127   $resolution = clock_getres(CLOCK_REALTIME);
128
129   clock_nanosleep(CLOCK_REALTIME, 1.5e9);
130   clock_nanosleep(CLOCK_REALTIME, time()*1e9 + 10e9, TIMER_ABSTIME);
131
132   my $ticktock = clock();
133
134   use Time::HiRes qw( stat lstat );
135
136   my @stat = stat("file");
137   my @stat = stat(FH);
138   my @stat = lstat("file");
139
140 =head1 DESCRIPTION
141
142 The C<Time::HiRes> module implements a Perl interface to the
143 C<usleep>, C<nanosleep>, C<ualarm>, C<gettimeofday>, and
144 C<setitimer>/C<getitimer> system calls, in other words, high
145 resolution time and timers. See the L</EXAMPLES> section below and the
146 test scripts for usage; see your system documentation for the
147 description of the underlying C<nanosleep> or C<usleep>, C<ualarm>,
148 C<gettimeofday>, and C<setitimer>/C<getitimer> calls.
149
150 If your system lacks C<gettimeofday()> or an emulation of it you don't
151 get C<gettimeofday()> or the one-argument form of C<tv_interval()>.
152 If your system lacks all of C<nanosleep()>, C<usleep()>,
153 C<select()>, and C<poll>, you don't get C<Time::HiRes::usleep()>,
154 C<Time::HiRes::nanosleep()>, or C<Time::HiRes::sleep()>.
155 If your system lacks both C<ualarm()> and C<setitimer()> you don't get
156 C<Time::HiRes::ualarm()> or C<Time::HiRes::alarm()>.
157
158 If you try to import an unimplemented function in the C<use> statement
159 it will fail at compile time.
160
161 If your subsecond sleeping is implemented with C<nanosleep()> instead
162 of C<usleep()>, you can mix subsecond sleeping with signals since
163 C<nanosleep()> does not use signals.  This, however, is not portable,
164 and you should first check for the truth value of
165 C<&Time::HiRes::d_nanosleep> to see whether you have nanosleep, and
166 then carefully read your C<nanosleep()> C API documentation for any
167 peculiarities.
168
169 If you are using C<nanosleep> for something else than mixing sleeping
170 with signals, give some thought to whether Perl is the tool you should
171 be using for work requiring nanosecond accuracies.
172
173 Remember that unless you are working on a I<hard realtime> system,
174 any clocks and timers will be imprecise, especially so if you are working
175 in a pre-emptive multiuser system.  Understand the difference between
176 I<wallclock time> and process time (in UNIX-like systems the sum of
177 I<user> and I<system> times).  Any attempt to sleep for X seconds will
178 most probably end up sleeping B<more> than that, but don't be surprised
179 if you end up sleeping slightly B<less>.
180
181 The following functions can be imported from this module.
182 No functions are exported by default.
183
184 =over 4
185
186 =item gettimeofday ()
187
188 In array context returns a two-element array with the seconds and
189 microseconds since the epoch.  In scalar context returns floating
190 seconds like C<Time::HiRes::time()> (see below).
191
192 =item usleep ( $useconds )
193
194 Sleeps for the number of microseconds (millionths of a second)
195 specified.  Returns the number of microseconds actually slept.
196 Can sleep for more than one second, unlike the C<usleep> system call.
197 Can also sleep for zero seconds, which often works like a I<thread yield>.
198 See also C<Time::HiRes::usleep()>, C<Time::HiRes::sleep()>, and
199 C<Time::HiRes::clock_nanosleep()>.
200
201 Do not expect usleep() to be exact down to one microsecond.
202
203 =item nanosleep ( $nanoseconds )
204
205 Sleeps for the number of nanoseconds (1e9ths of a second) specified.
206 Returns the number of nanoseconds actually slept (accurate only to
207 microseconds, the nearest thousand of them).  Can sleep for more than
208 one second.  Can also sleep for zero seconds, which often works like
209 a I<thread yield>.  See also C<Time::HiRes::sleep()>,
210 C<Time::HiRes::usleep()>, and C<Time::HiRes::clock_nanosleep()>.
211
212 Do not expect nanosleep() to be exact down to one nanosecond.
213 Getting even accuracy of one thousand nanoseconds is good.
214
215 =item ualarm ( $useconds [, $interval_useconds ] )
216
217 Issues a C<ualarm> call; the C<$interval_useconds> is optional and
218 will be zero if unspecified, resulting in C<alarm>-like behaviour.
219
220 Returns the remaining time in the alarm in microseconds, or C<undef>
221 if an error occurred.
222
223 ualarm(0) will cancel an outstanding ualarm().
224
225 Note that the interaction between alarms and sleeps is unspecified.
226
227 =item tv_interval 
228
229 tv_interval ( $ref_to_gettimeofday [, $ref_to_later_gettimeofday] )
230
231 Returns the floating seconds between the two times, which should have
232 been returned by C<gettimeofday()>. If the second argument is omitted,
233 then the current time is used.
234
235 =item time ()
236
237 Returns a floating seconds since the epoch. This function can be
238 imported, resulting in a nice drop-in replacement for the C<time>
239 provided with core Perl; see the L</EXAMPLES> below.
240
241 B<NOTE 1>: This higher resolution timer can return values either less
242 or more than the core C<time()>, depending on whether your platform
243 rounds the higher resolution timer values up, down, or to the nearest second
244 to get the core C<time()>, but naturally the difference should be never
245 more than half a second.  See also L</clock_getres>, if available
246 in your system.
247
248 B<NOTE 2>: Since Sunday, September 9th, 2001 at 01:46:40 AM GMT, when
249 the C<time()> seconds since epoch rolled over to 1_000_000_000, the
250 default floating point format of Perl and the seconds since epoch have
251 conspired to produce an apparent bug: if you print the value of
252 C<Time::HiRes::time()> you seem to be getting only five decimals, not
253 six as promised (microseconds).  Not to worry, the microseconds are
254 there (assuming your platform supports such granularity in the first
255 place).  What is going on is that the default floating point format of
256 Perl only outputs 15 digits.  In this case that means ten digits
257 before the decimal separator and five after.  To see the microseconds
258 you can use either C<printf>/C<sprintf> with C<"%.6f">, or the
259 C<gettimeofday()> function in list context, which will give you the
260 seconds and microseconds as two separate values.
261
262 =item sleep ( $floating_seconds )
263
264 Sleeps for the specified amount of seconds.  Returns the number of
265 seconds actually slept (a floating point value).  This function can
266 be imported, resulting in a nice drop-in replacement for the C<sleep>
267 provided with perl, see the L</EXAMPLES> below.
268
269 Note that the interaction between alarms and sleeps is unspecified.
270
271 =item alarm ( $floating_seconds [, $interval_floating_seconds ] )
272
273 The C<SIGALRM> signal is sent after the specified number of seconds.
274 Implemented using C<setitimer()> if available, C<ualarm()> if not.
275 The C<$interval_floating_seconds> argument is optional and will be
276 zero if unspecified, resulting in C<alarm()>-like behaviour.  This
277 function can be imported, resulting in a nice drop-in replacement for
278 the C<alarm> provided with perl, see the L</EXAMPLES> below.
279
280 Returns the remaining time in the alarm in seconds, or C<undef>
281 if an error occurred.
282
283 B<NOTE 1>: With some combinations of operating systems and Perl
284 releases C<SIGALRM> restarts C<select()>, instead of interrupting it.
285 This means that an C<alarm()> followed by a C<select()> may together
286 take the sum of the times specified for the C<alarm()> and the
287 C<select()>, not just the time of the C<alarm()>.
288
289 Note that the interaction between alarms and sleeps is unspecified.
290
291 =item setitimer ( $which, $floating_seconds [, $interval_floating_seconds ] )
292
293 Start up an interval timer: after a certain time, a signal ($which) arrives,
294 and more signals may keep arriving at certain intervals.  To disable
295 an "itimer", use C<$floating_seconds> of zero.  If the
296 C<$interval_floating_seconds> is set to zero (or unspecified), the
297 timer is disabled B<after> the next delivered signal.
298
299 Use of interval timers may interfere with C<alarm()>, C<sleep()>,
300 and C<usleep()>.  In standard-speak the "interaction is unspecified",
301 which means that I<anything> may happen: it may work, it may not.
302
303 In scalar context, the remaining time in the timer is returned.
304
305 In list context, both the remaining time and the interval are returned.
306
307 There are usually three or four interval timers (signals) available: the
308 C<$which> can be C<ITIMER_REAL>, C<ITIMER_VIRTUAL>, C<ITIMER_PROF>, or
309 C<ITIMER_REALPROF>.  Note that which ones are available depends: true
310 UNIX platforms usually have the first three, but only Solaris seems to
311 have C<ITIMER_REALPROF> (which is used to profile multithreaded programs).
312 Win32 unfortunately does not have interval timers.
313
314 C<ITIMER_REAL> results in C<alarm()>-like behaviour.  Time is counted in
315 I<real time>; that is, wallclock time.  C<SIGALRM> is delivered when
316 the timer expires.
317
318 C<ITIMER_VIRTUAL> counts time in (process) I<virtual time>; that is,
319 only when the process is running.  In multiprocessor/user/CPU systems
320 this may be more or less than real or wallclock time.  (This time is
321 also known as the I<user time>.)  C<SIGVTALRM> is delivered when the
322 timer expires.
323
324 C<ITIMER_PROF> counts time when either the process virtual time or when
325 the operating system is running on behalf of the process (such as I/O).
326 (This time is also known as the I<system time>.)  (The sum of user
327 time and system time is known as the I<CPU time>.)  C<SIGPROF> is
328 delivered when the timer expires.  C<SIGPROF> can interrupt system calls.
329
330 The semantics of interval timers for multithreaded programs are
331 system-specific, and some systems may support additional interval
332 timers.  For example, it is unspecified which thread gets the signals.
333 See your C<setitimer()> documentation.
334
335 =item getitimer ( $which )
336
337 Return the remaining time in the interval timer specified by C<$which>.
338
339 In scalar context, the remaining time is returned.
340
341 In list context, both the remaining time and the interval are returned.
342 The interval is always what you put in using C<setitimer()>.
343
344 =item clock_gettime ( $which )
345
346 Return as seconds the current value of the POSIX high resolution timer
347 specified by C<$which>.  All implementations that support POSIX high
348 resolution timers are supposed to support at least the C<$which> value
349 of C<CLOCK_REALTIME>, which is supposed to return results close to the
350 results of C<gettimeofday>, or the number of seconds since 00:00:00:00
351 January 1, 1970 Greenwich Mean Time (GMT).  Do not assume that
352 CLOCK_REALTIME is zero, it might be one, or something else.
353 Another potentially useful (but not available everywhere) value is
354 C<CLOCK_MONOTONIC>, which guarantees a monotonically increasing time
355 value (unlike time() or gettimeofday(), which can be adjusted).
356 See your system documentation for other possibly supported values.
357
358 =item clock_getres ( $which )
359
360 Return as seconds the resolution of the POSIX high resolution timer
361 specified by C<$which>.  All implementations that support POSIX high
362 resolution timers are supposed to support at least the C<$which> value
363 of C<CLOCK_REALTIME>, see L</clock_gettime>.
364
365 B<NOTE>: the resolution returned may be highly optimistic.  Even if
366 the resolution is high (a small number), all it means is that you'll
367 be able to specify the arguments to clock_gettime() and clock_nanosleep()
368 with that resolution.  The system might not actually be able to measure
369 events at that resolution, and the various overheads and the overall system
370 load are certain to affect any timings.
371
372 =item clock_nanosleep ( $which, $nanoseconds, $flags = 0)
373
374 Sleeps for the number of nanoseconds (1e9ths of a second) specified.
375 Returns the number of nanoseconds actually slept.  The $which is the
376 "clock id", as with clock_gettime() and clock_getres().  The flags
377 default to zero but C<TIMER_ABSTIME> can specified (must be exported
378 explicitly) which means that C<$nanoseconds> is not a time interval
379 (as is the default) but instead an absolute time.  Can sleep for more
380 than one second.  Can also sleep for zero seconds, which often works
381 like a I<thread yield>.  See also C<Time::HiRes::sleep()>,
382 C<Time::HiRes::usleep()>, and C<Time::HiRes::nanosleep()>.
383
384 Do not expect clock_nanosleep() to be exact down to one nanosecond.
385 Getting even accuracy of one thousand nanoseconds is good.
386
387 =item clock()
388
389 Return as seconds the I<process time> (user + system time) spent by
390 the process since the first call to clock() (the definition is B<not>
391 "since the start of the process", though if you are lucky these times
392 may be quite close to each other, depending on the system).  What this
393 means is that you probably need to store the result of your first call
394 to clock(), and subtract that value from the following results of clock().
395
396 The time returned also includes the process times of the terminated
397 child processes for which wait() has been executed.  This value is
398 somewhat like the second value returned by the times() of core Perl,
399 but not necessarily identical.  Note that due to backward
400 compatibility limitations the returned value may wrap around at about
401 2147 seconds or at about 36 minutes.
402
403 =item stat
404
405 =item stat FH
406
407 =item stat EXPR
408
409 =item lstat
410
411 =item lstat FH
412
413 =item lstat EXPR
414
415 As L<perlfunc/stat> or L<perlfunc/lstat>
416 but with the access/modify/change file timestamps
417 in subsecond resolution, if the operating system and the filesystem
418 both support such timestamps.  To override the standard stat():
419
420     use Time::HiRes qw(stat);
421
422 Test for the value of &Time::HiRes::d_hires_stat to find out whether
423 the operating system supports subsecond file timestamps: a value
424 larger than zero means yes. There are unfortunately no easy
425 ways to find out whether the filesystem supports such timestamps.
426 UNIX filesystems often do; NTFS does; FAT doesn't (FAT timestamp
427 granularity is B<two> seconds).
428
429 A zero return value of &Time::HiRes::d_hires_stat means that
430 Time::HiRes::stat is a no-op passthrough for CORE::stat()
431 (and likewise for lstat),
432 and therefore the timestamps will stay integers.  The same
433 thing will happen if the filesystem does not do subsecond timestamps,
434 even if the &Time::HiRes::d_hires_stat is non-zero.
435
436 In any case do not expect nanosecond resolution, or even a microsecond
437 resolution.  Also note that the modify/access timestamps might have
438 different resolutions, and that they need not be synchronized, e.g.
439 if the operations are
440
441     write
442     stat # t1
443     read
444     stat # t2
445
446 the access time stamp from t2 need not be greater-than the modify
447 time stamp from t1: it may be equal or I<less>.
448
449 =back
450
451 =head1 EXAMPLES
452
453   use Time::HiRes qw(usleep ualarm gettimeofday tv_interval);
454
455   $microseconds = 750_000;
456   usleep($microseconds);
457
458   # signal alarm in 2.5s & every .1s thereafter
459   ualarm(2_500_000, 100_000);
460   # cancel that ualarm
461   ualarm(0);
462
463   # get seconds and microseconds since the epoch
464   ($s, $usec) = gettimeofday();
465
466   # measure elapsed time 
467   # (could also do by subtracting 2 gettimeofday return values)
468   $t0 = [gettimeofday];
469   # do bunch of stuff here
470   $t1 = [gettimeofday];
471   # do more stuff here
472   $t0_t1 = tv_interval $t0, $t1;
473
474   $elapsed = tv_interval ($t0, [gettimeofday]);
475   $elapsed = tv_interval ($t0); # equivalent code
476
477   #
478   # replacements for time, alarm and sleep that know about
479   # floating seconds
480   #
481   use Time::HiRes;
482   $now_fractions = Time::HiRes::time;
483   Time::HiRes::sleep (2.5);
484   Time::HiRes::alarm (10.6666666);
485
486   use Time::HiRes qw ( time alarm sleep );
487   $now_fractions = time;
488   sleep (2.5);
489   alarm (10.6666666);
490
491   # Arm an interval timer to go off first at 10 seconds and
492   # after that every 2.5 seconds, in process virtual time
493
494   use Time::HiRes qw ( setitimer ITIMER_VIRTUAL time );
495
496   $SIG{VTALRM} = sub { print time, "\n" };
497   setitimer(ITIMER_VIRTUAL, 10, 2.5);
498
499   use Time::HiRes qw( clock_gettime clock_getres CLOCK_REALTIME );
500   # Read the POSIX high resolution timer.
501   my $high = clock_gettime(CLOCK_REALTIME);
502   # But how accurate we can be, really?
503   my $reso = clock_getres(CLOCK_REALTIME);
504
505   use Time::HiRes qw( clock_nanosleep TIMER_ABSTIME );
506   clock_nanosleep(CLOCK_REALTIME, 1e6);
507   clock_nanosleep(CLOCK_REALTIME, 2e9, TIMER_ABSTIME);
508
509   use Time::HiRes qw( clock );
510   my $clock0 = clock();
511   ... # Do something.
512   my $clock1 = clock();
513   my $clockd = $clock1 - $clock0;
514
515   use Time::HiRes qw( stat );
516   my ($atime, $mtime, $ctime) = (stat("istics"))[8, 9, 10];
517
518 =head1 C API
519
520 In addition to the perl API described above, a C API is available for
521 extension writers.  The following C functions are available in the
522 modglobal hash:
523
524   name             C prototype
525   ---------------  ----------------------
526   Time::NVtime     NV (*)()
527   Time::U2time     void (*)(pTHX_ UV ret[2])
528
529 Both functions return equivalent information (like C<gettimeofday>)
530 but with different representations.  The names C<NVtime> and C<U2time>
531 were selected mainly because they are operating system independent.
532 (C<gettimeofday> is Unix-centric, though some platforms like Win32 and
533 VMS have emulations for it.)
534
535 Here is an example of using C<NVtime> from C:
536
537   NV (*myNVtime)(); /* Returns -1 on failure. */
538   SV **svp = hv_fetch(PL_modglobal, "Time::NVtime", 12, 0);
539   if (!svp)         croak("Time::HiRes is required");
540   if (!SvIOK(*svp)) croak("Time::NVtime isn't a function pointer");
541   myNVtime = INT2PTR(NV(*)(), SvIV(*svp));
542   printf("The current time is: %" NVff "\n", (*myNVtime)());
543
544 =head1 DIAGNOSTICS
545
546 =head2 useconds or interval more than ...
547
548 In ualarm() you tried to use number of microseconds or interval (also
549 in microseconds) more than 1_000_000 and setitimer() is not available
550 in your system to emulate that case.
551
552 =head2 negative time not invented yet
553
554 You tried to use a negative time argument.
555
556 =head2 internal error: useconds < 0 (unsigned ... signed ...)
557
558 Something went horribly wrong-- the number of microseconds that cannot
559 become negative just became negative.  Maybe your compiler is broken?
560
561 =head2 useconds or uinterval equal to or more than 1000000
562
563 In some platforms it is not possible to get an alarm with subsecond
564 resolution and later than one second.
565
566 =head2 unimplemented in this platform
567
568 Some calls simply aren't available, real or emulated, on every platform.
569
570 =head1 CAVEATS
571
572 Notice that the core C<time()> maybe rounding rather than truncating.
573 What this means is that the core C<time()> may be reporting the time
574 as one second later than C<gettimeofday()> and C<Time::HiRes::time()>.
575
576 Adjusting the system clock (either manually or by services like ntp)
577 may cause problems, especially for long running programs that assume
578 a monotonously increasing time (note that all platforms do not adjust
579 time as gracefully as UNIX ntp does).  For example in Win32 (and derived
580 platforms like Cygwin and MinGW) the Time::HiRes::time() may temporarily
581 drift off from the system clock (and the original time())  by up to 0.5
582 seconds. Time::HiRes will notice this eventually and recalibrate.
583 Note that since Time::HiRes 1.77 the clock_gettime(CLOCK_MONOTONIC)
584 might help in this (in case your system supports CLOCK_MONOTONIC).
585
586 Some systems have APIs but not implementations: for example QNX and Haiku
587 have the interval timer APIs but not the functionality.
588
589 In OS X clock_getres(), clock_gettime() and clock_nanosleep() are
590 emulated using the Mach timers; as a side effect of being emulated
591 the CLOCK_REALTIME and CLOCK_MONOTONIC are the same timer.
592
593 =head1 SEE ALSO
594
595 Perl modules L<BSD::Resource>, L<Time::TAI64>.
596
597 Your system documentation for C<clock>, C<clock_gettime>,
598 C<clock_getres>, C<clock_nanosleep>, C<clock_settime>, C<getitimer>,
599 C<gettimeofday>, C<setitimer>, C<sleep>, C<stat>, C<ualarm>.
600
601 =head1 AUTHORS
602
603 D. Wegscheid <wegscd@whirlpool.com>
604 R. Schertler <roderick@argon.org>
605 J. Hietaniemi <jhi@iki.fi>
606 G. Aas <gisle@aas.no>
607
608 =head1 COPYRIGHT AND LICENSE
609
610 Copyright (c) 1996-2002 Douglas E. Wegscheid.  All rights reserved.
611
612 Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Jarkko Hietaniemi.
613 All rights reserved.
614
615 Copyright (C) 2011, 2012, 2013 Andrew Main (Zefram) <zefram@fysh.org>
616
617 This program is free software; you can redistribute it and/or modify
618 it under the same terms as Perl itself.
619
620 =cut