Date: Wednesday March 06, 2019 @ 18:34 Author: argrath Update of /cvsroot/perldocjp/docs/modules/Time-HiRes-1.55 In directory sf-cvs:/tmp/cvs-serv73259/modules/Time-HiRes-1.55 Modified Files: HiRes.pod Log Message: add original =================================================================== File: HiRes.pod Status: Up-to-date Working revision: 1.4 Wed Mar 6 09:34:55 2019 Repository revision: 1.4 /cvsroot/perldocjp/docs/modules/Time-HiRes-1.55/HiRes.pod,v Existing Tags: No Tags Exist -------------- next part -------------- Index: docs/modules/Time-HiRes-1.55/HiRes.pod diff -u docs/modules/Time-HiRes-1.55/HiRes.pod:1.3 docs/modules/Time-HiRes-1.55/HiRes.pod:1.4 --- docs/modules/Time-HiRes-1.55/HiRes.pod:1.3 Tue Feb 8 01:15:18 2011 +++ docs/modules/Time-HiRes-1.55/HiRes.pod Wed Mar 6 18:34:55 2019 @@ -1,11 +1,17 @@ =encoding euc-jp -=head1 ̾Á° +=head1 NAME + +=begin original + +Time::HiRes - High resolution alarm, sleep, gettimeofday, interval timers + +=end original Time::HiRes - ¹âÀºÅÙ¤Îalarm, sleep, gettimeofday, ¥¤¥ó¥¿¡¼¥Ð¥ë¡¦¥¿¥¤¥Þ¡¼ -=head1 ³µÍ× +=head1 SYNOPSIS use Time::HiRes qw( usleep ualarm gettimeofday tv_interval ); @@ -29,12 +35,23 @@ alarm ($floating_seconds, $floating_interval); use Time::HiRes qw( setitimer getitimer - ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF ITIMER_REALPROF ); + ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF ITIMER_REALPROF ); setitimer ($which, $floating_seconds, $floating_interval ); getitimer ($which); -=head1 ÀâÌÀ +=head1 DESCRIPTION + +=begin original + +The C<Time::HiRes> module implements a Perl interface to the C<usleep>, +C<ualarm>, C<gettimeofday>, and C<setitimer>/C<getitimer> system calls, in other +words, high resolution time and timers. See the L</EXAMPLES> section below +and the test scripts for usage; see your system documentation for the +description of the underlying C<nanosleep> or C<usleep>, C<ualarm>, +C<gettimeofday>, and C<setitimer>/C<getitimer> calls. + +=end original C<Time::HiRes> ¥â¥¸¥å¡¼¥ë¤ÏC<usleep>,C<ualarm>, C<gettimeofday>, ¤½¤·¤Æ C<setitimer>/C<getitimer> ¥·¥¹¥Æ¥à¥³¡¼¥à¡¢¸À¤¤´¹¤¨¤ì¤Ð¹âÀºÅ٤λþ¹ï¤È @@ -44,6 +61,17 @@ ¤½¤·¤Æ C<setitimer>/C<getitimer>¤Ë¤Ä¤¤¤Æ¤Ï¡¢¤¢¤Ê¤¿¤Î¥·¥¹¥Æ¥à¤Î¥É¥¥å¥á¥ó¥È¤ò ¤´Í÷¤¯¤À¤µ¤¤¡£ +=begin original + +If your system lacks C<gettimeofday()> or an emulation of it you don't +get C<gettimeofday()> or the one-argument form of C<tv_interval()>. If your system lacks all of +C<nanosleep()>, C<usleep()>, and C<select()>, you don't get +C<Time::HiRes::usleep()> or C<Time::HiRes::sleep()>. If your system lacks both +C<ualarm()> and C<setitimer()> you don't get +C<Time::HiRes::ualarm()> or C<Time::HiRes::alarm()>. + +=end original + ¤¢¤Ê¤¿¤Î¥·¥¹¥Æ¥à¤ËC<gettimeofday()>¤ä¤½¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤¬¤Ê¤±¤ì¤Ð¡¢ C<gettimeofday()>¤ä°ú¿ô1¤Ä¤Î·Á¤Ç¤ÎC<tv_interval()>¤Ï»È¤¨¤Þ¤»¤ó¡£ ¤¢¤Ê¤¿¤Î¥·¥¹¥Æ¥à¤ËC<nanosleep()>, C<usleep()>, ¤½¤·¤Æ C<select()>,¤ÎÁ´¤Æ¤¬ @@ -51,9 +79,29 @@ ¤¢¤Ê¤¿¤Î¥·¥¹¥Æ¥à¤ËC<ualarm()> and C<setitimer()> ¤ÎξÊý¤¬¤Ê¤±¤ì¤Ð C<Time::HiRes::ualarm()> ¤ä C<Time::HiRes::alarm()>¤¬»È¤¨¤Þ¤»¤ó¡£ +=begin original + +If you try to import an unimplemented function in the C<use> statement +it will fail at compile time. + +=end original + C<use>¥¹¥Æ¡¼¥È¥á¥ó¥È¤Î¤Ê¤«¤Ç¼ÂÁõ¤µ¤ì¤Æ¤¤¤Ê¤¤´Ø¿ô¤ò¥¤¥ó¥Ý¡¼¥È¤·¤è¤¦¤È¤¹¤ì¤Ð¡¢ ¥³¥ó¥Ñ¥¤¥ë»þ¤Ë¼ºÇÔ¤·¤Þ¤¹¡£ +=begin original + +If your subsecond sleeping is implemented with C<nanosleep()> instead of +C<usleep()>, you can mix subsecond sleeping with signals since +C<nanosleep()> does not use signals. This, however is unportable, and you +should first check for the truth value of C<&Time::HiRes::d_nanosleep> to +see whether you have nanosleep, and then carefully read your +C<nanosleep()> C API documentation for any peculiarities. (There is no +separate interface to call C<nanosleep()>; just use C<Time::HiRes::sleep()> +or C<Time::HiRes::usleep()> with small enough values.) + +=end original + ¤¢¤Ê¤¿¤Î£±Éðʲ¼¤Îsleep¤¬C<usleep()>¤Ç¤Ï¤Ê¤¯C<nanosleep()>¤Ç¼ÂÁõ¤µ¤ì¤Æ¤¤¤ì¤Ð¡¢ C<nanosleep()>¤Ï¥·¥°¥Ê¥ë¤ò»È¤ï¤Ê¤¤¤Î¤Ç¡¢£±Éðʲ¼¤Îsleep¤È¥·¥°¥Ê¥ë¤òº®ºß¤µ¤»¤ë ¤³¤È¤¬¤Ç¤¤Þ¤¹¡£¤·¤«¤·¤³¤ì¤Ï°Ü¿¢À¤ò·ç¤¤Þ¤¹¡£¤½¤·¤Æ¤Þ¤ººÇ½é¤Ënanosleep¤ò @@ -63,10 +111,25 @@ ¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ï¤¢¤ê¤Þ¤»¤ó;½½Ê¬¤Ë¾®¤µ¤ÊÃͤÇñ¤ËC<Time::HiRes::sleep()>¤ä C<Time::HiRes::usleep()>¤ò¸Æ¤Ö¤À¤±¤Ç¤¹¡£) +=begin original + +Unless using C<nanosleep> for mixing sleeping with signals, give +some thought to whether Perl is the tool you should be using for work +requiring nanosecond accuracies. + +=end original + sleep¤È¥·¥°¥Ê¥ë¤òº®ºß¤µ¤»¤ë¤¿¤á¤ËC<nanosleep>¤ò»È¤ï¤Ê¤±¤ì¤Ð¡¢ Perl¤¬¥Ê¥ÎÉäÎÀµ³Î¤µ¤òÍ׵ᤵ¤ì¤ë»Å»ö¤Î¤¿¤á¤Ë»È¤¦¤Ù¤¥Ä¡¼¥ë¤Ç¤¢¤ë¤« ¤È¤¤¤¦µ¿Ì䤬¤¢¤ê¤Þ¤¹¡£ +=begin original + +The following functions can be imported from this module. +No functions are exported by default. + +=end original + ¤³¤Î¥â¥¸¥å¡¼¥ë¤«¤é°Ê²¼¤Î´Ø¿ô¤ò¥¤¥ó¥Ý¡¼¥È¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£ ¥Ç¥Õ¥©¥ë¥È¤Ç¥¨¥¯¥¹¥Ý¡¼¥È¤µ¤ì¤ë´Ø¿ô¤Ï¤¢¤ê¤Þ¤»¤ó¡£ @@ -74,18 +137,41 @@ =item gettimeofday () +=begin original + +In array context returns a two-element array with the seconds and +microseconds since the epoch. In scalar context returns floating +seconds like C<Time::HiRes::time()> (see below). + +=end original + ÇÛÎó¥³¥ó¥Æ¥¥¹¥È¤Ç¤Ï¥¨¥Ý¥Ã¥¯¤«¤é¤ÎÉäȥޥ¤¥¯¥íÉÃ2¤Ä¤ÎÍ×ÁǤÎÇÛÎó¤òÊÖ¤·¤Þ¤¹¡£ ¥¹¥«¥é¡¼¡¦¥³¥ó¥Æ¥¥¹¥È¤Ç¤Ï¡¢C<Time::HiRes::time()>¤Î¤è¤¦¤ËÉäò ÉâÆ°¾®¿ôÅÀ¿ô¤ÇÊÖ¤·¤Þ¤¹¡Ê²¼µ»²¾È¡Ë¡£ =item usleep ( $useconds ) +=begin original + +Sleeps for the number of microseconds specified. Returns the number +of microseconds actually slept. Can sleep for more than one second, +unlike the C<usleep> system call. See also C<Time::HiRes::sleep()> below. + +=end original + »ØÄꤵ¤ì¤¿¥Þ¥¤¥¯¥íÉÿô¡¢sleep¤·¤Þ¤¹¡£¼ÂºÝ¤Ësleep¤·¤¿¥Þ¥¤¥¯¥íÉÿô¤ò ÊÖ¤·¤Þ¤¹¡£C<usleep>¥·¥¹¥Æ¥à¡¦¥³¡¼¥ë¤È¤Ï°ã¤¤¡¢1Éðʾåsleep¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£ ²¼µ¤ÎC<Time::HiRes::sleep()>¤â¤´Í÷¤¯¤À¤µ¤¤¡£ =item ualarm ( $useconds [, $interval_useconds ] ) +=begin original + +Issues a C<ualarm> call; the C<$interval_useconds> is optional and +will be zero if unspecified, resulting in C<alarm>-like behaviour. + +=end original + C<ualarm>¥³¡¼¥ë¤òȯ¹Ô¤·¤Þ¤¹;C<$interval_useconds>¤Ï¥ª¥×¥·¥ç¥ó¤Ç¡¢ »ØÄꤵ¤ì¤Ê¤±¤ì¤Ð0¤Ë¤Ê¤ê¡¢¤½¤Î·ë²Ì¤ÏC<alarm>¤Î¤è¤¦¤ÊÆ°¤¤ò¤·¤Þ¤¹¡£ @@ -93,21 +179,65 @@ tv_interval ( $ref_to_gettimeofday [, $ref_to_later_gettimeofday] ) +=begin original + +Returns the floating seconds between the two times, which should have +been returned by C<gettimeofday()>. If the second argument is omitted, +then the current time is used. + +=end original + 2¤Ä¤Î»þ¹ï¤Î»þ´Ö¤òÉâÆ°¾®¿ôÅÀ¤ÎÉÿô¤òÊÖ¤·¤Þ¤¹¡£2¤Ä¤Î»þ¹ï¤ÏC<gettimeofday()>¤Ç ÊÖ¤µ¤ì¤¿¤â¤Î¤Ç¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£2ÈÖÌܤΰú¿ô¤¬¾Êά¤µ¤ì¤ë¤È¡¢ ¸½ºß¤Î»þ¹ï¤¬»È¤ï¤ì¤Þ¤¹¡£ =item time () +=begin original + +Returns a floating seconds since the epoch. This function can be +imported, resulting in a nice drop-in replacement for the C<time> +provided with core Perl; see the L</EXAMPLES> below. + +=end original + ÉâÆ°¾®¿ôÅÀ¤Ç¥¨¥Ý¥Ã¥¯¤«¤é¤ÎÉÿô¤òÊÖ¤·¤Þ¤¹¡£¤³¤Î´Ø¿ô¤Ï¥¤¥ó¥Ý¡¼¥È¤¹¤ë ¤³¤È¤¬¤Ç¤¤Þ¤¹¡¢¤½¤Î·ë²Ì¡¢Perl¤Î¥³¥¢¤ÇÄ󶡤µ¤ì¤ëº¹¤·¹þ¤ß¼°¤ËC<time>¤ò ÃÖ¤´¹¤¨¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹;²¼µ¤ÎL</»ÈÍÑÎã>¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ +=begin original + +B<NOTE 1>: This higher resolution timer can return values either less +or more than the core C<time()>, depending on whether your platform +rounds the higher resolution timer values up, down, or to the nearest second +to get the core C<time()>, but naturally the difference should be never +more than half a second. + +=end original + B<Ãí°Õ 1>: ¤³¤Î¹âÀºÅÙ¤Îtime¤Ï¡¢¤¢¤Ê¤¿¤Î¥×¥é¥Ã¥È¥Û¡¼¥à¤¬¥³¥¢¤ÎC<time()>¤ò ÆÀ¤ë¤¿¤á¤Ë¡¢¤è¤ê¹âÀºÅ٤λþ¹ï¤òÀÚ¤ê¾å¤²¤¿¤ê¡¢ÀÚ¤ê¼Î¤Æ¤¿¤ê¡¢°ìÈֶᤤÉÃ¤Ë ¤¹¤ë¤Î¤¤¤º¤ì¤«¤Ë¤è¤Ã¤Æ¡¢¥³¥¢¤ÎC<time()>¤è¤ê¤â¿¤«¤Ã¤¿¤ê¡¢¾¯¤Ê¤«¤Ã¤¿¤ê ¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£¤·¤«¤·ÅöÁ³¡¢¤½¤Îº¹¤Ï0.5Éäò±Û¤¨¤ë¤³¤È¤Ï¤¢¤ê¤¨¤Þ¤»¤ó¡£ +=begin original + +B<NOTE 2>: Since Sunday, September 9th, 2001 at 01:46:40 AM GMT, when +the C<time()> seconds since epoch rolled over to 1_000_000_000, the +default floating point format of Perl and the seconds since epoch have +conspired to produce an apparent bug: if you print the value of +C<Time::HiRes::time()> you seem to be getting only five decimals, not six +as promised (microseconds). Not to worry, the microseconds are there +(assuming your platform supports such granularity in first place). +What is going on is that the default floating point format of Perl +only outputs 15 digits. In this case that means ten digits before the +decimal separator and five after. To see the microseconds you can use +either C<printf>/C<sprintf> with C<"%.6f">, or the C<gettimeofday()> function in +list context, which will give you the seconds and microseconds as two +separate values. + +=end original + B<Ãí°Õ 2>: 2001ǯ9·î9Æü ÆüÍËÆü GMT¤Î¸áÁ° 1:46:40¤è¤ê¡¢ ¥¨¥Ý¥Ã¥¯¤«¤é¤ÎC<time()>Éäϡ¢1_000_000_000¤òĶ¤¨¤Æ¤¤¤Þ¤¹¡£ Perl¤Ç¤Î¥Ç¥Õ¥©¥ë¥È¤ÎÉâÆ°¾®¿ôÅÀ¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤È¥¨¥Ý¥Ã¥¯¤«¤é¤ÎÉÿô¤¬ @@ -123,6 +253,15 @@ =item sleep ( $floating_seconds ) +=begin original + +Sleeps for the specified amount of seconds. Returns the number of +seconds actually slept (a floating point value). This function can be +imported, resulting in a nice drop-in replacement for the C<sleep> +provided with perl, see the L</EXAMPLES> below. + +=end original + »ØÄꤵ¤ì¤¿Éÿô¡¢sleep¤·¤Þ¤¹¡£¼ÂºÝ¤Ësleep¤·¤¿Éÿô¤ò(ÉâÆ°¾®¿ôÅÀ¤ÎÃͤÇ) ÊÖ¤·¤Þ¤¹¡£¤³¤Î´Ø¿ô¤Ï¥¤¥ó¥Ý¡¼¥È¤¹¤ë ¤³¤È¤¬¤Ç¤¤Þ¤¹¡¢¤½¤Î·ë²Ì¡¢Perl¤Î¥³¥¢¤ÇÄ󶡤µ¤ì¤ëº¹¤·¹þ¤ß¼°¤ËC<sleep>¤ò @@ -130,6 +269,16 @@ =item alarm ( $floating_seconds [, $interval_floating_seconds ] ) +=begin original + +The C<SIGALRM> signal is sent after the specified number of seconds. +Implemented using C<ualarm()>. The C<$interval_floating_seconds> argument +is optional and will be zero if unspecified, resulting in C<alarm()>-like +behaviour. This function can be imported, resulting in a nice drop-in +replacement for the C<alarm> provided with perl, see the L</EXAMPLES> below. + +=end original + »ØÄꤵ¤ìÉÿô¸å¡¢C<SIGALRM>¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤Þ¤¹¡£C<ualarm()>¤ò»È¤Ã¤Æ ¼ÂÁõ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£C<$interval_floating_seconds>°ú¿ô¤Ï ¥ª¥×¥·¥ç¥ó¤Ç»ØÄꤵ¤ì¤Ê¤¤¤È0¤Ë¤Ê¤ê¤Þ¤¹¡£¤½¤Î·ë²Ì¡¢C<alarm()>¤Î¤è¤¦¤Ê @@ -137,6 +286,16 @@ ¤³¤È¤¬¤Ç¤¤Þ¤¹¡£¤½¤Î·ë²Ì¡¢Perl¤Î¥³¥¢¤ÇÄ󶡤µ¤ì¤ëº¹¤·¹þ¤ß¼°¤ËC<alarm>¤ò ÃÖ¤´¹¤¨¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹;²¼µ¤ÎL</»ÈÍÑÎã>¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ +=begin original + +B<NOTE 1>: With some operating system and Perl release combinations +C<SIGALRM> restarts C<select()>, instead of interuping it. +This means that an C<alarm()> followed by a C<select()> +may together take the sum of the times specified for the the +C<alarm()> and the C<select()>, not just the time of the C<alarm()>. + +=end original + B<Ãí°Õ 1>: ¥ª¥Ú¥ì¡¼¥Æ¥£¥ó¥°¡¦¥·¥¹¥Æ¥à¤ÈPerl¤Î¥ê¥ê¡¼¥¹¤Î ÁȤ߹ç¤ï¤»¤Ë¤è¤Ã¤Æ¤ÏC<SIGALRM>¤¬ÃæÃǤµ¤»¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢C<select()>¤ò ºÆ³«»Ï¤µ¤»¤ë¤³¤È¤â¤¢¤ê¤Þ¤¹¡£¤³¤ì¤ÏC<alarm()>¤Î¸å¤ËC<select()>¤ò @@ -146,20 +305,61 @@ =item setitimer ( $which, $floating_seconds [, $interval_floating_seconds ] ) +=begin original + +Start up an interval timer: after a certain time, a signal arrives, +and more signals may keep arriving at certain intervals. To disable a +timer, use C<$floating_seconds> of zero. If the C<$interval_floating_seconds> +is set to zero (or unspecified), the timer is disabled B<after> the +next delivered signal. + +=end original + ¥¤¥ó¥¿¡¼¥Ð¥ë¡¦¥¿¥¤¥Þ¡¼¤ò³«»Ï¤µ¤»¤Þ¤¹;°ìÄê¤Î»þ´Ö¸å¡¢¥·¥°¥Ê¥ë¤¬ÆϤ¡¢ ¤¢¤ë´Ö³Ö¤Ç¥·¥°¥Ê¥ë¤¬ÆϤ³¤±¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£¥¿¥¤¥Þ¡¼¤ò»ß¤á¤ë¤Ë¤Ï¡¢ C<$floating_seconds>¤ò0¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£C<$interval_floating_seconds>¤Ë 0¤¬»ØÄꤵ¤ì¤ë¤È(¤¢¤ë¤¤¤Ï»ØÄꤵ¤ì¤Ê¤¤¤È)¡¢¥¿¥¤¥Þ¡¼¤Ï¼¡¤Ë¥·¥°¥Ê¥ë¤¬ÆϤ¤¤¿ B<¸å¤Ë>»ß¤á¤é¤ì¤Þ¤¹¡£ +=begin original + +Use of interval timers may interfere with C<alarm()>, C<sleep()>, +and C<usleep()>. In standard-speak the "interaction is unspecified", +which means that I<anything> may happen: it may work, it may not. + +=end original + ¥¤¥ó¥¿¡¼¥Ð¥ë¡¦¥¿¥¤¥Þ¡¼¤ò»È¤¦¤³¤È¤ÏC<alarm()>, C<sleep()>¡¢C<usleep()>¤Ë ¤è¤Ã¤Æ¼ÙË⤵¤ì¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£É¸½àŪ¤Ë¤Ï¡ÖÁê¸ßºîÍѤÏÆÃÄꤵ¤ì¤Æ¤¤¤Þ¤»¤ó¡× ¤Ä¤Þ¤ê¤ÏI<²¿¤¬>µ¯¤¤ë¤«¤ï¤«¤ê¤Þ¤»¤ó:Æ°¤¯¤«¤â¤·¤ì¤Þ¤»¤ó¤·¡¢¤½¤¦¤Ç¤Ê¤¤¤«¤â¤·¤ì¤Þ¤»¤ó¡£ +=begin original + +In scalar context, the remaining time in the timer is returned. + +=end original + ¥¹¥«¥é¡¼¡¦¥³¥ó¥Æ¥¥¹¥È¤Ç¤Ï¥¿¥¤¥Þ¡¼¤Ç¤Î»Ä¤ê»þ´Ö¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ +=begin original + +In list context, both the remaining time and the interval are returned. + +=end original + ¥ê¥¹¥È¡¦¥³¥ó¥Æ¥¥¹¥È¤Ç¤Ï¡¢»Ä¤ê»þ´Ö¤È¥¤¥ó¥¿¡¼¥Ð¥ë¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ +=begin original + +There are usually three or four interval timers available: the C<$which> +can be C<ITIMER_REAL>, C<ITIMER_VIRTUAL>, C<ITIMER_PROF>, or C<ITIMER_REALPROF>. +Note that which ones are available depends: true UNIX platforms usually +have the first three, but (for example) Win32 and Cygwin have only +C<ITIMER_REAL>, and only Solaris seems to have C<ITIMER_REALPROF> (which is +used to profile multithreaded programs). + +=end original + Ä̾ï3¤Ä¤¢¤ë¤¤¤Ï4¤Ä¤Î¥¤¥ó¥¿¡¼¥Ð¥ë¡¦¥¿¥¤¥Þ¡¼¤¬ÍøÍѲÄǽ¤Ç¤¹:C<$which>¤Ï C<ITIMER_REAL>, C<ITIMER_VIRTUAL>, C<ITIMER_PROF>, ¤¢¤ë¤¤¤Ï C<ITIMER_REALPROF>¤Ë ¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£¤É¤ì¤¬ÍøÍѤǤ¤ë¤«¤Ï°Ê²¼¤Î¤³¤È¤Ë°Í¸¤·¤Þ¤¹:ËÜÅö¤ÎUNIX @@ -167,22 +367,57 @@ C<ITIMER_REAL>¤·¤«¤â¤Ã¤Æ¤¤¤Þ¤»¤ó¡£Solaris¤ÏC<ITIMER_REALPROF>¤ò»ý¤Ã¤Æ¤¤¤ë¤è¤¦¤Ç¤¹ (¤³¤ì¤Ï¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¤Ê¥×¥í¥°¥é¥à¤ò¥×¥í¥Õ¥¡¥¤¥ë¤¹¤ë¤¿¤á¤Ë»È¤ï¤ì¤Þ¤¹)¡£ +=begin original + +C<ITIMER_REAL> results in C<alarm()>-like behavior. Time is counted in +I<real time>; that is, wallclock time. C<SIGALRM> is delivered when +the timer expires. + +=end original + C<ITIMER_REAL>¤Ï·ë²Ì¤È¤·¤ÆC<alarm()>¤Î¤è¤¦¤ÊÆ°¤¤Ë¤·¤Þ¤¹¡£ »þ´Ö¤ÏI<¼Â»þ´Ö>;¤Ä¤Þ¤êÊÉ»þ·×¤Î»þ´Ö¤Ç·×¤é¤ì¤Þ¤¹¡£ ¥¿¥¤¥Þ¡¼¤¬»þ´ÖÀÚ¤ì¤Ë¤Ê¤ë¤ÈC<SIGALRM>¤¬Á÷¤é¤ì¤Þ¤¹¡£ +=begin original + +C<ITIMER_VIRTUAL> counts time in (process) I<virtual time>; that is, only +when the process is running. In multiprocessor/user/CPU systems this +may be more or less than real or wallclock time. (This time is also +known as the I<user time>.) C<SIGVTALRM> is delivered when the timer expires. + +=end original + C<ITIMER_VIRTUAL>¤Ï(¥×¥í¥»¥¹)I<²¾Áۤλþ´Ö>¤Ç»þ´Ö¤ò·×¤ê¤Þ¤¹¡¨ ¤Ä¤Þ¤ê¥×¥í¥»¥¹¤¬¼Â¹Ô¤·¤Æ¤¤¤ë¤È¤¤À¤±¤Ç¤¹¡£¥Þ¥ë¥Á¥×¥í¥»¥Ã¥µ/¥æ¡¼¥¶/CPU ¤Î ¥·¥¹¥Æ¥à¤Ç¤Ï¤³¤ì¤Ï¼Â»þ´Ö¤¢¤ë¤¤¤ÏÊÉ»þ·×¤Î»þ´Ö¤È¤Ï¿¤«¤Ã¤¿¤ê¡¢¾¯¤Ê¤«¤Ã¤¿¤ê¤·¤Þ¤¹¡£ (¤³¤Î»þ´Ö¤ÏI<¥æ¡¼¥¶¡¼»þ´Ö(user time)>¤È¤â¸Æ¤Ð¤ì¤Þ¤¹¡£¥¿¥¤¥Þ¡¼¤¬ »þ´ÖÀÚ¤ì¤Ë¤Ê¤ë¤ÈC<SIGVTALRM>¤¬Á÷¤é¤ì¤Þ¤¹¡£ +=begin original + +C<ITIMER_PROF> counts time when either the process virtual time or when +the operating system is running on behalf of the process (such as I/O). +(This time is also known as the I<system time>.) (The sum of user +time and system time is known as the I<CPU time>.) C<SIGPROF> is +delivered when the timer expires. C<SIGPROF> can interrupt system calls. + +=end original + C<ITIMER_PROF> ¤Ï¥×¥í¥»¥¹²¾ÁÛ»þ´Ö¡¢¤¢¤ë¤¤¤Ï(I/O¤Î¤è¤¦¤Ë)¥×¥í¥»¥¹¤ÎȾʬ¤Ç ¥ª¥Ú¥ì¡¼¥Æ¥£¥ó¥°¡¦¥·¥¹¥Æ¥à¤¬Áö¤Ã¤Æ¤¤¤ë»þ´Ö¤ò·×¤ê¤Þ¤¹¡£ (¤³¤Î»þ´Ö¤ÏI<¥·¥¹¥Æ¥à»þ´Ö(system time)>¤È¤â¸Æ¤Ð¤ì¤Þ¤¹¡£) ¥¿¥¤¥Þ¡¼¤¬»þ´ÖÀÚ¤ì¤Ë¤Ê¤ë¤È¡¢C<SIGPROF>¤¬Á÷¤é¤ì¤Þ¤¹¡£C<SIGPROF>¤Ï ¥·¥¹¥Æ¥à¡¦¥³¡¼¥ë¤òÃæÃǤµ¤»¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£ +=begin original + +The semantics of interval timers for multithreaded programs are +system-specific, and some systems may support additional interval +timers. See your C<setitimer()> documentation. + +=end original + ¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¤Ê¥×¥í¥°¥é¥à¤Ç¤Î¥¤¥ó¥¿¡¼¥Ð¥ë¡¦¥¿¥¤¥Þ¡¼¤Î°ÕÌ£¤Ï ¥·¥¹¥Æ¥à¤Ë¤è¤ê¤Þ¤¹¡£¤½¤·¤Æ¥·¥¹¥Æ¥à¤Ë¤è¤Ã¤Æ¤Ï¡¢¤µ¤é¤Ë¾¤Î ¥¤¥ó¥¿¡¼¥Ð¥ë¡¦¥¿¥¤¥Þ¡¼¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ @@ -190,28 +425,73 @@ =item getitimer ( $which ) +=begin original + +Return the remaining time in the interval timer specified by C<$which>. + +=end original + C<$which>¤Ç»ØÄꤵ¤ì¤¿¥¤¥ó¥¿¡¼¥Ð¥ë¡¦¥¿¥¤¥Þ¡¼¤Ç¤Î»Ä¤ê»þ´Ö¤òÊÖ¤·¤Þ¤¹¡£ +=begin original + +In scalar context, the remaining time is returned. + +=end original + ¥¹¥«¥é¡¼¡¦¥³¥ó¥Æ¥¥¹¥È¤Ç¤Ï¡¢»Ä¤ê»þ´Ö¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ +=begin original + +In list context, both the remaining time and the interval are returned. +The interval is always what you put in using C<setitimer()>. + +=end original + ¥ê¥¹¥È¡¦¥³¥ó¥Æ¥¥¹¥È¤Ç¤Ï»Ä¤ê»þ´Ö¤È¥¤¥ó¥¿¡¼¥Ð¥ë¤ÎξÊý¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ ¥¤¥ó¥¿¡¼¥Ð¥ë¤Ï¾ï¤Ë¡¢C<setitimer()>¤ò»È¤Ã¤¿¤È¤¤ËÆþ¤ì¤¿¤â¤Î¤Ç¤¹¡£ =back -=head1 »ÈÍÑÎã +=head1 EXAMPLES use Time::HiRes qw(usleep ualarm gettimeofday tv_interval); $microseconds = 750_000; usleep $microseconds; +=begin original + + # signal alarm in 2.5s & every .1s thereafter + ualarm 2_500_000, 100_000; + +=end original + # 2.5Éø塢¤½¤Î¸å¤Ï0.1¹Ô¤´¤È¤Ë¥·¥°¥Ê¥ë¡¦¥¢¥é¡¼¥à ualarm 2_500_000, 100_000; +=begin original + + # get seconds and microseconds since the epoch + ($s, $usec) = gettimeofday; + +=end original + # ¥¨¥Ý¥Ã¥¯¤«¤é¤ÎÉäȥޥ¤¥¯¥íÉäò¼èÆÀ ($s, $usec) = gettimeofday; +=begin original + + # measure elapsed time + # (could also do by subtracting 2 gettimeofday return values) + $t0 = [gettimeofday]; + # do bunch of stuff here + $t1 = [gettimeofday]; + # do more stuff here + $t0_t1 = tv_interval $t0, $t1; + +=end original + # ·Ð²á»þ´Ö¤Î·×¬ # (2¤Ä¤Îgettimeofday¤ÎÌá¤êÃͤò°ú¤¯¤³¤È¤Ë¤è¤Ã¤Æ¤â²Äǽ¤Ç¤¹) $t0 = [gettimeofday]; @@ -221,7 +501,20 @@ $t0_t1 = tv_interval $t0, $t1; $elapsed = tv_interval ($t0, [gettimeofday]); - $elapsed = tv_interval ($t0); # equivalent code + $elapsed = tv_interval ($t0); # equivalent code + +=begin original + + # + # replacements for time, alarm and sleep that know about + # floating seconds + # + use Time::HiRes; + $now_fractions = Time::HiRes::time; + Time::HiRes::sleep (2.5); + Time::HiRes::alarm (10.6666666); + +=end original # # time, alarm ¤½¤·¤Æ sleep¤òÉâÆ°¾®¿ôÅÀ¤Ç¤ÎÉ䬤狼¤ë @@ -237,6 +530,13 @@ sleep (2.5); alarm (10.6666666); +=begin original + + # Arm an interval timer to go off first at 10 seconds and + # after that every 2.5 seconds, in process virtual time + +=end original + # ¥×¥í¥»¥¹²¾ÁÛ»þ´Ö¤ÇºÇ½é¤Ë10Éᢤ½¤Î¸å¤Ï2.5Éä´¤È¤Ë # ¤ä¤Ã¤Æ¤¯¤ë¥¤¥ó¥¿¡¼¥Ð¥ë¥¿¥¤¥Þ¡¼¤òÁõÈ÷¤¹¤ë @@ -247,21 +547,54 @@ =head1 C API +=begin original + +In addition to the perl API described above, a C API is available for +extension writers. The following C functions are available in the +modglobal hash: + +=end original + ³ÈÄ¥¤ò½ñ¤¯¿Í¤Ë¤Ï¾åµ¤Îperl API¤Ë²Ã¤¨¤Æ¡¢C API¤òÍøÍѤ¹¤ë¤³¤È¤¬ ÍøÍѤǤ¤Þ¤¹¡£°Ê²¼¤ÎC¤Î´Ø¿ô¤¬modglobal¥Ï¥Ã¥·¥å¤ÇÍøÍѤ¹¤ë¤³¤È¤¬ ¤Ç¤¤Þ¤¹: +=begin original + + name C prototype + --------------- ---------------------- + Time::NVtime double (*)() + Time::U2time void (*)(UV ret[2]) + +=end original + ´Ø¿ô̾ C¥×¥í¥È¥¿¥¤¥× --------------- ---------------------- Time::NVtime double (*)() Time::U2time void (*)(UV ret[2]) +=begin original + +Both functions return equivalent information (like C<gettimeofday>) +but with different representations. The names C<NVtime> and C<U2time> +were selected mainly because they are operating system independent. +(C<gettimeofday> is Unix-centric, though some platforms like VMS have +emulations for it.) + +=end original + ´Ø¿ô¤ÏξÊý¤È¤â(C<gettimeofday>¤Î¤è¤¦¤Ê)Ʊ¤¸¾ðÊó¤òÊÖ¤·¤Þ¤¹¡£ ¤·¤«¤·¤½¤Îɽ¸½¤¬°ã¤¤¤Þ¤¹¡£C<NVtime> ¤È C<U2time>¤È¤¤¤¦Ì¾Á°¤Ï¼ç¤Ë ¥ª¥Ú¥ì¡¼¥Æ¥£¥ó¥°¡¦¥·¥¹¥Æ¥à¤Ë°Í¸¤·¤Æ¤¤¤Ê¤¤¤¿¤á¤ËÁªÂò¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ (VMS¤Î¤è¤¦¤Ë¤¤¤¯¤Ä¤«¤Î¥×¥é¥Ã¥È¥Û¡¼¥à¤Ç¤Ï¤½¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤ò È÷¤¨¤Æ¤¤¤Þ¤¹¤¬¡¢C<gettimeofday>¤ÏUnixÃ濴Ū¤Ç¤¹¡£) +=begin original + +Here is an example of using C<NVtime> from C: + +=end original + C¤«¤éC<NVtime>¤ò»È¤Ã¤¿¤È¤¤ÎÎã¤ò°Ê²¼¤Ë¼¨¤·¤Þ¤¹: double (*myNVtime)(); @@ -271,26 +604,46 @@ myNVtime = INT2PTR(double(*)(), SvIV(*svp)); printf("The current time is: %f\n", (*myNVtime)()); -=head1 DIAGNOSTICS(¿ÇÃÇ) +=head1 DIAGNOSTICS =head2 negative time not invented yet -(=¥Þ¥¤¥Ê¥¹¤Î»þ¹ï¤Ï¤Þ¤ÀȯÌÀ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó) +=begin original + +You tried to use a negative time argument. + +=end original + °ú¿ô¤È¤·¤Æ¥Þ¥¤¥Ê¥¹¤Î»þ¹ï¤ò»È¤ª¤¦¤È¤·¤Þ¤·¤¿¡£ =head2 internal error: useconds < 0 (unsigned ... signed ...) +=begin original + +Something went horribly wrong-- the number of microseconds that cannot +become negative just became negative. Maybe your compiler is broken? + +=end original + ²¿¤«¤Ò¤É¤¤¾ã³²¤¬¤ª¤¤Þ¤·¤¿ -- ¥Þ¥¤¥Ê¥¹¤Ë¤Ê¤ë¤Ï¤º¤Î¤Ê¤¤¥Þ¥¤¥¯¥íÉÿô¤Ï ¥Þ¥¤¥Ê¥¹¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¤¤Þ¤·¤¿¡£¥³¥ó¥Ñ¥¤¥é¤¬²õ¤ì¤Æ¤¤¤ë¤Î¤«¤â¡© -=head1 Ãí°Õ +=head1 CAVEATS + +=begin original + +Notice that the core C<time()> maybe rounding rather than truncating. +What this means is that the core C<time()> may be reporting the time as one second +later than C<gettimeofday()> and C<Time::HiRes::time()>. + +=end original ¥³¥¢¤ÎC<time()>¤¬ÀÚ¤ê¼Î¤Æ¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢»Í¼Î¸ÞÆþ¤¹¤ë¤«¤â¤·¤ì¤Ê¤¤¤³¤È¤Ë Ãí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£¤³¤ì¤Ï¥³¥¢¤ÎC<time()>¤¬C<gettimeofday()>¤ä C<Time::HiRes::time()>¤è¤ê¤â1ÉÃÃÙ¤¤»þ´Ö¤òÊó¹ð¤¹¤ë¤«¤â¤·¤ì¤Ê¤¤¤È¤¤¤¦ ¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£ -=head1 ºî¼Ô +=head1 AUTHORS D. Wegscheid <wegsc****@whirl*****> R. Schertler <roder****@argon*****> @@ -310,3 +663,5 @@ Àî¹ç¹§Åµ(GCD00****@nifty*****) +=cut +