xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/ext/Time/HiRes/HiRes.pm (revision 0:68f95e015346)
1*0Sstevel@tonic-gatepackage Time::HiRes;
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateuse strict;
4*0Sstevel@tonic-gateuse vars qw($VERSION $XS_VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD);
5*0Sstevel@tonic-gate
6*0Sstevel@tonic-gaterequire Exporter;
7*0Sstevel@tonic-gaterequire DynaLoader;
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gate@ISA = qw(Exporter DynaLoader);
10*0Sstevel@tonic-gate
11*0Sstevel@tonic-gate@EXPORT = qw( );
12*0Sstevel@tonic-gate@EXPORT_OK = qw (usleep sleep ualarm alarm gettimeofday time tv_interval
13*0Sstevel@tonic-gate		 getitimer setitimer
14*0Sstevel@tonic-gate		 ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF ITIMER_REALPROF
15*0Sstevel@tonic-gate		 d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer
16*0Sstevel@tonic-gate		 d_nanosleep);
17*0Sstevel@tonic-gate
18*0Sstevel@tonic-gate$VERSION = '1.59';
19*0Sstevel@tonic-gate$XS_VERSION = $VERSION;
20*0Sstevel@tonic-gate$VERSION = eval $VERSION;
21*0Sstevel@tonic-gate
22*0Sstevel@tonic-gatesub AUTOLOAD {
23*0Sstevel@tonic-gate    my $constname;
24*0Sstevel@tonic-gate    ($constname = $AUTOLOAD) =~ s/.*:://;
25*0Sstevel@tonic-gate    die "&Time::HiRes::constant not defined" if $constname eq 'constant';
26*0Sstevel@tonic-gate    my ($error, $val) = constant($constname);
27*0Sstevel@tonic-gate    if ($error) { die $error; }
28*0Sstevel@tonic-gate    {
29*0Sstevel@tonic-gate	no strict 'refs';
30*0Sstevel@tonic-gate	*$AUTOLOAD = sub { $val };
31*0Sstevel@tonic-gate    }
32*0Sstevel@tonic-gate    goto &$AUTOLOAD;
33*0Sstevel@tonic-gate}
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gatebootstrap Time::HiRes;
36*0Sstevel@tonic-gate
37*0Sstevel@tonic-gate# Preloaded methods go here.
38*0Sstevel@tonic-gate
39*0Sstevel@tonic-gatesub tv_interval {
40*0Sstevel@tonic-gate    # probably could have been done in C
41*0Sstevel@tonic-gate    my ($a, $b) = @_;
42*0Sstevel@tonic-gate    $b = [gettimeofday()] unless defined($b);
43*0Sstevel@tonic-gate    (${$b}[0] - ${$a}[0]) + ((${$b}[1] - ${$a}[1]) / 1_000_000);
44*0Sstevel@tonic-gate}
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gate# Autoload methods go after =cut, and are processed by the autosplit program.
47*0Sstevel@tonic-gate
48*0Sstevel@tonic-gate1;
49*0Sstevel@tonic-gate__END__
50*0Sstevel@tonic-gate
51*0Sstevel@tonic-gate=head1 NAME
52*0Sstevel@tonic-gate
53*0Sstevel@tonic-gateTime::HiRes - High resolution alarm, sleep, gettimeofday, interval timers
54*0Sstevel@tonic-gate
55*0Sstevel@tonic-gate=head1 SYNOPSIS
56*0Sstevel@tonic-gate
57*0Sstevel@tonic-gate  use Time::HiRes qw( usleep ualarm gettimeofday tv_interval );
58*0Sstevel@tonic-gate
59*0Sstevel@tonic-gate  usleep ($microseconds);
60*0Sstevel@tonic-gate
61*0Sstevel@tonic-gate  ualarm ($microseconds);
62*0Sstevel@tonic-gate  ualarm ($microseconds, $interval_microseconds);
63*0Sstevel@tonic-gate
64*0Sstevel@tonic-gate  $t0 = [gettimeofday];
65*0Sstevel@tonic-gate  ($seconds, $microseconds) = gettimeofday;
66*0Sstevel@tonic-gate
67*0Sstevel@tonic-gate  $elapsed = tv_interval ( $t0, [$seconds, $microseconds]);
68*0Sstevel@tonic-gate  $elapsed = tv_interval ( $t0, [gettimeofday]);
69*0Sstevel@tonic-gate  $elapsed = tv_interval ( $t0 );
70*0Sstevel@tonic-gate
71*0Sstevel@tonic-gate  use Time::HiRes qw ( time alarm sleep );
72*0Sstevel@tonic-gate
73*0Sstevel@tonic-gate  $now_fractions = time;
74*0Sstevel@tonic-gate  sleep ($floating_seconds);
75*0Sstevel@tonic-gate  alarm ($floating_seconds);
76*0Sstevel@tonic-gate  alarm ($floating_seconds, $floating_interval);
77*0Sstevel@tonic-gate
78*0Sstevel@tonic-gate  use Time::HiRes qw( setitimer getitimer
79*0Sstevel@tonic-gate		      ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF ITIMER_REALPROF );
80*0Sstevel@tonic-gate
81*0Sstevel@tonic-gate  setitimer ($which, $floating_seconds, $floating_interval );
82*0Sstevel@tonic-gate  getitimer ($which);
83*0Sstevel@tonic-gate
84*0Sstevel@tonic-gate=head1 DESCRIPTION
85*0Sstevel@tonic-gate
86*0Sstevel@tonic-gateThe C<Time::HiRes> module implements a Perl interface to the C<usleep>,
87*0Sstevel@tonic-gateC<ualarm>, C<gettimeofday>, and C<setitimer>/C<getitimer> system calls, in other
88*0Sstevel@tonic-gatewords, high resolution time and timers. See the L</EXAMPLES> section below
89*0Sstevel@tonic-gateand the test scripts for usage; see your system documentation for the
90*0Sstevel@tonic-gatedescription of the underlying C<nanosleep> or C<usleep>, C<ualarm>,
91*0Sstevel@tonic-gateC<gettimeofday>, and C<setitimer>/C<getitimer> calls.
92*0Sstevel@tonic-gate
93*0Sstevel@tonic-gateIf your system lacks C<gettimeofday()> or an emulation of it you don't
94*0Sstevel@tonic-gateget C<gettimeofday()> or the one-argument form of C<tv_interval()>.  If your system lacks all of
95*0Sstevel@tonic-gateC<nanosleep()>, C<usleep()>, and C<select()>, you don't get
96*0Sstevel@tonic-gateC<Time::HiRes::usleep()> or C<Time::HiRes::sleep()>.  If your system lacks both
97*0Sstevel@tonic-gateC<ualarm()> and C<setitimer()> you don't get
98*0Sstevel@tonic-gateC<Time::HiRes::ualarm()> or C<Time::HiRes::alarm()>.
99*0Sstevel@tonic-gate
100*0Sstevel@tonic-gateIf you try to import an unimplemented function in the C<use> statement
101*0Sstevel@tonic-gateit will fail at compile time.
102*0Sstevel@tonic-gate
103*0Sstevel@tonic-gateIf your subsecond sleeping is implemented with C<nanosleep()> instead of
104*0Sstevel@tonic-gateC<usleep()>, you can mix subsecond sleeping with signals since
105*0Sstevel@tonic-gateC<nanosleep()> does not use signals.  This, however is unportable, and you
106*0Sstevel@tonic-gateshould first check for the truth value of C<&Time::HiRes::d_nanosleep> to
107*0Sstevel@tonic-gatesee whether you have nanosleep, and then carefully read your
108*0Sstevel@tonic-gateC<nanosleep()> C API documentation for any peculiarities.  (There is no
109*0Sstevel@tonic-gateseparate interface to call C<nanosleep()>; just use C<Time::HiRes::sleep()>
110*0Sstevel@tonic-gateor C<Time::HiRes::usleep()> with small enough values.)
111*0Sstevel@tonic-gate
112*0Sstevel@tonic-gateUnless using C<nanosleep> for mixing sleeping with signals, give
113*0Sstevel@tonic-gatesome thought to whether Perl is the tool you should be using for work
114*0Sstevel@tonic-gaterequiring nanosecond accuracies.
115*0Sstevel@tonic-gate
116*0Sstevel@tonic-gateThe following functions can be imported from this module.
117*0Sstevel@tonic-gateNo functions are exported by default.
118*0Sstevel@tonic-gate
119*0Sstevel@tonic-gate=over 4
120*0Sstevel@tonic-gate
121*0Sstevel@tonic-gate=item gettimeofday ()
122*0Sstevel@tonic-gate
123*0Sstevel@tonic-gateIn array context returns a two-element array with the seconds and
124*0Sstevel@tonic-gatemicroseconds since the epoch.  In scalar context returns floating
125*0Sstevel@tonic-gateseconds like C<Time::HiRes::time()> (see below).
126*0Sstevel@tonic-gate
127*0Sstevel@tonic-gate=item usleep ( $useconds )
128*0Sstevel@tonic-gate
129*0Sstevel@tonic-gateSleeps for the number of microseconds specified.  Returns the number
130*0Sstevel@tonic-gateof microseconds actually slept.  Can sleep for more than one second,
131*0Sstevel@tonic-gateunlike the C<usleep> system call. See also C<Time::HiRes::sleep()> below.
132*0Sstevel@tonic-gate
133*0Sstevel@tonic-gate=item ualarm ( $useconds [, $interval_useconds ] )
134*0Sstevel@tonic-gate
135*0Sstevel@tonic-gateIssues a C<ualarm> call; the C<$interval_useconds> is optional and
136*0Sstevel@tonic-gatewill be zero if unspecified, resulting in C<alarm>-like behaviour.
137*0Sstevel@tonic-gate
138*0Sstevel@tonic-gate=item tv_interval
139*0Sstevel@tonic-gate
140*0Sstevel@tonic-gatetv_interval ( $ref_to_gettimeofday [, $ref_to_later_gettimeofday] )
141*0Sstevel@tonic-gate
142*0Sstevel@tonic-gateReturns the floating seconds between the two times, which should have
143*0Sstevel@tonic-gatebeen returned by C<gettimeofday()>. If the second argument is omitted,
144*0Sstevel@tonic-gatethen the current time is used.
145*0Sstevel@tonic-gate
146*0Sstevel@tonic-gate=item time ()
147*0Sstevel@tonic-gate
148*0Sstevel@tonic-gateReturns a floating seconds since the epoch. This function can be
149*0Sstevel@tonic-gateimported, resulting in a nice drop-in replacement for the C<time>
150*0Sstevel@tonic-gateprovided with core Perl; see the L</EXAMPLES> below.
151*0Sstevel@tonic-gate
152*0Sstevel@tonic-gateB<NOTE 1>: This higher resolution timer can return values either less
153*0Sstevel@tonic-gateor more than the core C<time()>, depending on whether your platform
154*0Sstevel@tonic-gaterounds the higher resolution timer values up, down, or to the nearest second
155*0Sstevel@tonic-gateto get the core C<time()>, but naturally the difference should be never
156*0Sstevel@tonic-gatemore than half a second.
157*0Sstevel@tonic-gate
158*0Sstevel@tonic-gateB<NOTE 2>: Since Sunday, September 9th, 2001 at 01:46:40 AM GMT, when
159*0Sstevel@tonic-gatethe C<time()> seconds since epoch rolled over to 1_000_000_000, the
160*0Sstevel@tonic-gatedefault floating point format of Perl and the seconds since epoch have
161*0Sstevel@tonic-gateconspired to produce an apparent bug: if you print the value of
162*0Sstevel@tonic-gateC<Time::HiRes::time()> you seem to be getting only five decimals, not six
163*0Sstevel@tonic-gateas promised (microseconds).  Not to worry, the microseconds are there
164*0Sstevel@tonic-gate(assuming your platform supports such granularity in first place).
165*0Sstevel@tonic-gateWhat is going on is that the default floating point format of Perl
166*0Sstevel@tonic-gateonly outputs 15 digits.  In this case that means ten digits before the
167*0Sstevel@tonic-gatedecimal separator and five after.  To see the microseconds you can use
168*0Sstevel@tonic-gateeither C<printf>/C<sprintf> with C<"%.6f">, or the C<gettimeofday()> function in
169*0Sstevel@tonic-gatelist context, which will give you the seconds and microseconds as two
170*0Sstevel@tonic-gateseparate values.
171*0Sstevel@tonic-gate
172*0Sstevel@tonic-gate=item sleep ( $floating_seconds )
173*0Sstevel@tonic-gate
174*0Sstevel@tonic-gateSleeps for the specified amount of seconds.  Returns the number of
175*0Sstevel@tonic-gateseconds actually slept (a floating point value).  This function can be
176*0Sstevel@tonic-gateimported, resulting in a nice drop-in replacement for the C<sleep>
177*0Sstevel@tonic-gateprovided with perl, see the L</EXAMPLES> below.
178*0Sstevel@tonic-gate
179*0Sstevel@tonic-gate=item alarm ( $floating_seconds [, $interval_floating_seconds ] )
180*0Sstevel@tonic-gate
181*0Sstevel@tonic-gateThe C<SIGALRM> signal is sent after the specified number of seconds.
182*0Sstevel@tonic-gateImplemented using C<ualarm()>.  The C<$interval_floating_seconds> argument
183*0Sstevel@tonic-gateis optional and will be zero if unspecified, resulting in C<alarm()>-like
184*0Sstevel@tonic-gatebehaviour.  This function can be imported, resulting in a nice drop-in
185*0Sstevel@tonic-gatereplacement for the C<alarm> provided with perl, see the L</EXAMPLES> below.
186*0Sstevel@tonic-gate
187*0Sstevel@tonic-gateB<NOTE 1>: With some operating system and Perl release combinations
188*0Sstevel@tonic-gateC<SIGALRM> restarts C<select()>, instead of interuping it.
189*0Sstevel@tonic-gateThis means that an C<alarm()> followed by a C<select()>
190*0Sstevel@tonic-gatemay together take the sum of the times specified for the the
191*0Sstevel@tonic-gateC<alarm()> and the C<select()>, not just the time of the C<alarm()>.
192*0Sstevel@tonic-gate
193*0Sstevel@tonic-gate=item setitimer ( $which, $floating_seconds [, $interval_floating_seconds ] )
194*0Sstevel@tonic-gate
195*0Sstevel@tonic-gateStart up an interval timer: after a certain time, a signal arrives,
196*0Sstevel@tonic-gateand more signals may keep arriving at certain intervals.  To disable a
197*0Sstevel@tonic-gatetimer, use C<$floating_seconds> of zero.  If the C<$interval_floating_seconds>
198*0Sstevel@tonic-gateis set to zero (or unspecified), the timer is disabled B<after> the
199*0Sstevel@tonic-gatenext delivered signal.
200*0Sstevel@tonic-gate
201*0Sstevel@tonic-gateUse of interval timers may interfere with C<alarm()>, C<sleep()>,
202*0Sstevel@tonic-gateand C<usleep()>.  In standard-speak the "interaction is unspecified",
203*0Sstevel@tonic-gatewhich means that I<anything> may happen: it may work, it may not.
204*0Sstevel@tonic-gate
205*0Sstevel@tonic-gateIn scalar context, the remaining time in the timer is returned.
206*0Sstevel@tonic-gate
207*0Sstevel@tonic-gateIn list context, both the remaining time and the interval are returned.
208*0Sstevel@tonic-gate
209*0Sstevel@tonic-gateThere are usually three or four interval timers available: the C<$which>
210*0Sstevel@tonic-gatecan be C<ITIMER_REAL>, C<ITIMER_VIRTUAL>, C<ITIMER_PROF>, or C<ITIMER_REALPROF>.
211*0Sstevel@tonic-gateNote that which ones are available depends: true UNIX platforms usually
212*0Sstevel@tonic-gatehave the first three, but (for example) Win32 and Cygwin have only
213*0Sstevel@tonic-gateC<ITIMER_REAL>, and only Solaris seems to have C<ITIMER_REALPROF> (which is
214*0Sstevel@tonic-gateused to profile multithreaded programs).
215*0Sstevel@tonic-gate
216*0Sstevel@tonic-gateC<ITIMER_REAL> results in C<alarm()>-like behavior.  Time is counted in
217*0Sstevel@tonic-gateI<real time>; that is, wallclock time.  C<SIGALRM> is delivered when
218*0Sstevel@tonic-gatethe timer expires.
219*0Sstevel@tonic-gate
220*0Sstevel@tonic-gateC<ITIMER_VIRTUAL> counts time in (process) I<virtual time>; that is, only
221*0Sstevel@tonic-gatewhen the process is running.  In multiprocessor/user/CPU systems this
222*0Sstevel@tonic-gatemay be more or less than real or wallclock time.  (This time is also
223*0Sstevel@tonic-gateknown as the I<user time>.)  C<SIGVTALRM> is delivered when the timer expires.
224*0Sstevel@tonic-gate
225*0Sstevel@tonic-gateC<ITIMER_PROF> counts time when either the process virtual time or when
226*0Sstevel@tonic-gatethe operating system is running on behalf of the process (such as I/O).
227*0Sstevel@tonic-gate(This time is also known as the I<system time>.)  (The sum of user
228*0Sstevel@tonic-gatetime and system time is known as the I<CPU time>.)  C<SIGPROF> is
229*0Sstevel@tonic-gatedelivered when the timer expires.  C<SIGPROF> can interrupt system calls.
230*0Sstevel@tonic-gate
231*0Sstevel@tonic-gateThe semantics of interval timers for multithreaded programs are
232*0Sstevel@tonic-gatesystem-specific, and some systems may support additional interval
233*0Sstevel@tonic-gatetimers.  See your C<setitimer()> documentation.
234*0Sstevel@tonic-gate
235*0Sstevel@tonic-gate=item getitimer ( $which )
236*0Sstevel@tonic-gate
237*0Sstevel@tonic-gateReturn the remaining time in the interval timer specified by C<$which>.
238*0Sstevel@tonic-gate
239*0Sstevel@tonic-gateIn scalar context, the remaining time is returned.
240*0Sstevel@tonic-gate
241*0Sstevel@tonic-gateIn list context, both the remaining time and the interval are returned.
242*0Sstevel@tonic-gateThe interval is always what you put in using C<setitimer()>.
243*0Sstevel@tonic-gate
244*0Sstevel@tonic-gate=back
245*0Sstevel@tonic-gate
246*0Sstevel@tonic-gate=head1 EXAMPLES
247*0Sstevel@tonic-gate
248*0Sstevel@tonic-gate  use Time::HiRes qw(usleep ualarm gettimeofday tv_interval);
249*0Sstevel@tonic-gate
250*0Sstevel@tonic-gate  $microseconds = 750_000;
251*0Sstevel@tonic-gate  usleep $microseconds;
252*0Sstevel@tonic-gate
253*0Sstevel@tonic-gate  # signal alarm in 2.5s & every .1s thereafter
254*0Sstevel@tonic-gate  ualarm 2_500_000, 100_000;
255*0Sstevel@tonic-gate
256*0Sstevel@tonic-gate  # get seconds and microseconds since the epoch
257*0Sstevel@tonic-gate  ($s, $usec) = gettimeofday;
258*0Sstevel@tonic-gate
259*0Sstevel@tonic-gate  # measure elapsed time
260*0Sstevel@tonic-gate  # (could also do by subtracting 2 gettimeofday return values)
261*0Sstevel@tonic-gate  $t0 = [gettimeofday];
262*0Sstevel@tonic-gate  # do bunch of stuff here
263*0Sstevel@tonic-gate  $t1 = [gettimeofday];
264*0Sstevel@tonic-gate  # do more stuff here
265*0Sstevel@tonic-gate  $t0_t1 = tv_interval $t0, $t1;
266*0Sstevel@tonic-gate
267*0Sstevel@tonic-gate  $elapsed = tv_interval ($t0, [gettimeofday]);
268*0Sstevel@tonic-gate  $elapsed = tv_interval ($t0);	# equivalent code
269*0Sstevel@tonic-gate
270*0Sstevel@tonic-gate  #
271*0Sstevel@tonic-gate  # replacements for time, alarm and sleep that know about
272*0Sstevel@tonic-gate  # floating seconds
273*0Sstevel@tonic-gate  #
274*0Sstevel@tonic-gate  use Time::HiRes;
275*0Sstevel@tonic-gate  $now_fractions = Time::HiRes::time;
276*0Sstevel@tonic-gate  Time::HiRes::sleep (2.5);
277*0Sstevel@tonic-gate  Time::HiRes::alarm (10.6666666);
278*0Sstevel@tonic-gate
279*0Sstevel@tonic-gate  use Time::HiRes qw ( time alarm sleep );
280*0Sstevel@tonic-gate  $now_fractions = time;
281*0Sstevel@tonic-gate  sleep (2.5);
282*0Sstevel@tonic-gate  alarm (10.6666666);
283*0Sstevel@tonic-gate
284*0Sstevel@tonic-gate  # Arm an interval timer to go off first at 10 seconds and
285*0Sstevel@tonic-gate  # after that every 2.5 seconds, in process virtual time
286*0Sstevel@tonic-gate
287*0Sstevel@tonic-gate  use Time::HiRes qw ( setitimer ITIMER_VIRTUAL time );
288*0Sstevel@tonic-gate
289*0Sstevel@tonic-gate  $SIG{VTALRM} = sub { print time, "\n" };
290*0Sstevel@tonic-gate  setitimer(ITIMER_VIRTUAL, 10, 2.5);
291*0Sstevel@tonic-gate
292*0Sstevel@tonic-gate=head1 C API
293*0Sstevel@tonic-gate
294*0Sstevel@tonic-gateIn addition to the perl API described above, a C API is available for
295*0Sstevel@tonic-gateextension writers.  The following C functions are available in the
296*0Sstevel@tonic-gatemodglobal hash:
297*0Sstevel@tonic-gate
298*0Sstevel@tonic-gate  name             C prototype
299*0Sstevel@tonic-gate  ---------------  ----------------------
300*0Sstevel@tonic-gate  Time::NVtime     double (*)()
301*0Sstevel@tonic-gate  Time::U2time     void (*)(UV ret[2])
302*0Sstevel@tonic-gate
303*0Sstevel@tonic-gateBoth functions return equivalent information (like C<gettimeofday>)
304*0Sstevel@tonic-gatebut with different representations.  The names C<NVtime> and C<U2time>
305*0Sstevel@tonic-gatewere selected mainly because they are operating system independent.
306*0Sstevel@tonic-gate(C<gettimeofday> is Unix-centric, though some platforms like VMS have
307*0Sstevel@tonic-gateemulations for it.)
308*0Sstevel@tonic-gate
309*0Sstevel@tonic-gateHere is an example of using C<NVtime> from C:
310*0Sstevel@tonic-gate
311*0Sstevel@tonic-gate  double (*myNVtime)();
312*0Sstevel@tonic-gate  SV **svp = hv_fetch(PL_modglobal, "Time::NVtime", 12, 0);
313*0Sstevel@tonic-gate  if (!svp)         croak("Time::HiRes is required");
314*0Sstevel@tonic-gate  if (!SvIOK(*svp)) croak("Time::NVtime isn't a function pointer");
315*0Sstevel@tonic-gate  myNVtime = INT2PTR(double(*)(), SvIV(*svp));
316*0Sstevel@tonic-gate  printf("The current time is: %f\n", (*myNVtime)());
317*0Sstevel@tonic-gate
318*0Sstevel@tonic-gate=head1 DIAGNOSTICS
319*0Sstevel@tonic-gate
320*0Sstevel@tonic-gate=head2 negative time not invented yet
321*0Sstevel@tonic-gate
322*0Sstevel@tonic-gateYou tried to use a negative time argument.
323*0Sstevel@tonic-gate
324*0Sstevel@tonic-gate=head2 internal error: useconds < 0 (unsigned ... signed ...)
325*0Sstevel@tonic-gate
326*0Sstevel@tonic-gateSomething went horribly wrong-- the number of microseconds that cannot
327*0Sstevel@tonic-gatebecome negative just became negative.  Maybe your compiler is broken?
328*0Sstevel@tonic-gate
329*0Sstevel@tonic-gate=head1 CAVEATS
330*0Sstevel@tonic-gate
331*0Sstevel@tonic-gateNotice that the core C<time()> maybe rounding rather than truncating.
332*0Sstevel@tonic-gateWhat this means is that the core C<time()> may be reporting the time
333*0Sstevel@tonic-gateas one second later than C<gettimeofday()> and C<Time::HiRes::time()>.
334*0Sstevel@tonic-gate
335*0Sstevel@tonic-gateAdjusting the system clock (either manually or by services like ntp)
336*0Sstevel@tonic-gatemay cause problems, especially for long running programs that assume
337*0Sstevel@tonic-gatea monotonously increasing time (note that all platforms do not adjust
338*0Sstevel@tonic-gatetime as gracefully as UNIX ntp does).  For example in Win32 (and derived
339*0Sstevel@tonic-gateplatforms like Cygwin and MinGW) the Time::HiRes::time() may temporarily
340*0Sstevel@tonic-gatedrift off from the system clock (and the original time())  by up to 0.5
341*0Sstevel@tonic-gateseconds. Time::HiRes will notice this eventually and recalibrate.
342*0Sstevel@tonic-gate
343*0Sstevel@tonic-gate=head1 AUTHORS
344*0Sstevel@tonic-gate
345*0Sstevel@tonic-gateD. Wegscheid <wegscd@whirlpool.com>
346*0Sstevel@tonic-gateR. Schertler <roderick@argon.org>
347*0Sstevel@tonic-gateJ. Hietaniemi <jhi@iki.fi>
348*0Sstevel@tonic-gateG. Aas <gisle@aas.no>
349*0Sstevel@tonic-gate
350*0Sstevel@tonic-gate=head1 COPYRIGHT AND LICENSE
351*0Sstevel@tonic-gate
352*0Sstevel@tonic-gateCopyright (c) 1996-2002 Douglas E. Wegscheid.  All rights reserved.
353*0Sstevel@tonic-gate
354*0Sstevel@tonic-gateCopyright (c) 2002,2003,2004 Jarkko Hietaniemi.  All rights reserved.
355*0Sstevel@tonic-gate
356*0Sstevel@tonic-gateThis program is free software; you can redistribute it and/or modify
357*0Sstevel@tonic-gateit under the same terms as Perl itself.
358*0Sstevel@tonic-gate
359*0Sstevel@tonic-gate=cut
360