From: Jarkko Hietaniemi Date: Wed, 28 Jul 1999 13:55:57 +0000 (+0000) Subject: Talk more about subsecond things in perlfunc. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=68f8bed405ed7c00a1f880915d7296baf4ae4184;p=p5sagit%2Fp5-mst-13.2.git Talk more about subsecond things in perlfunc. (Yes, redundant with perlfaq8.) p4raw-id: //depot/cfgperl@3810 --- diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 2ced382..7072d72 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -396,8 +396,8 @@ undefined, or you might be able to use the C interface to access setitimer(2) if your system supports it. The Time::HiRes module from CPAN may also prove useful. -It is usually a mistake to intermix C -and C calls. +It is usually a mistake to intermix C and C calls. +(C may be internally implemented in your system with C) If you want to use C to time out a system call you need to use an C/C pair. You can't rely on the alarm causing the system call to @@ -2227,11 +2227,13 @@ In scalar context, returns the ctime(3) value: $now_string = localtime; # e.g., "Thu Oct 13 04:54:34 1994" This scalar value is B locale dependent, see L, but -instead a Perl builtin. Also see the C module, and the -strftime(3) and mktime(3) function available via the POSIX module. To -get somewhat similar but locale dependent date strings, set up your -locale environment variables appropriately (please see L) -and try for example: +instead a Perl builtin. Also see the C module +(to convert the second, minutes, hours, ... back to seconds since the +stroke of midnight the 1st of January 1970, the value returned by +time()), and the strftime(3) and mktime(3) function available via the +POSIX module. To get somewhat similar but locale dependent date +strings, set up your locale environment variables appropriately +(please see L) and try for example: use POSIX qw(strftime); $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime; @@ -3742,8 +3744,9 @@ however, because your process might not be scheduled right away in a busy multitasking system. For delays of finer granularity than one second, you may use Perl's -C interface to access setitimer(2) if your system supports it, -or else see L above. +C interface to access setitimer(2) if your system supports +it, or else see L above. The Time::HiRes module from CPAN +may also help. See also the POSIX module's C function. @@ -4610,6 +4613,11 @@ considers to be the epoch (that's 00:00:00, January 1, 1904 for MacOS, and 00:00:00 UTC, January 1, 1970 for most other systems). Suitable for feeding to C and C. +For measuring time in better granularity than one second, +you may use either the Time::HiRes module from CPAN, or +if you have gettimeofday(2), you may be able to use the +C interface of Perl, see L for details. + =item times Returns a four-element list giving the user and system times, in