Date: Wednesday March 06, 2019 @ 21:29 Author: argrath Update of /cvsroot/perldocjp/docs/modules/Time-HiRes-1.9719 In directory sf-cvs:/tmp/cvs-serv68405/modules/Time-HiRes-1.9719 Added Files: HiRes.pod Log Message: in progress =================================================================== File: HiRes.pod Status: Up-to-date Working revision: 1.1 Wed Mar 6 12:29:20 2019 Repository revision: 1.1 /cvsroot/perldocjp/docs/modules/Time-HiRes-1.9719/HiRes.pod,v Existing Tags: No Tags Exist -------------- next part -------------- Index: docs/modules/Time-HiRes-1.9719/HiRes.pod diff -u /dev/null docs/modules/Time-HiRes-1.9719/HiRes.pod:1.1 --- /dev/null Wed Mar 6 21:29:20 2019 +++ docs/modules/Time-HiRes-1.9719/HiRes.pod Wed Mar 6 21:29:20 2019 @@ -0,0 +1,1178 @@ + +=encoding euc-jp + +=head1 NAME + +=begin original + +Time::HiRes - High resolution alarm, sleep, gettimeofday, interval timers + +=end original + +Time::HiRes - ¹âÀºÅ٤Πalarm, sleep, gettimeofday, ¥¤¥ó¥¿¡¼¥Ð¥ë¡¦¥¿¥¤¥Þ¡¼ + +=head1 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 = [gettimeofday]; + ($seconds, $microseconds) = gettimeofday; + + $elapsed = tv_interval ( $t0, [$seconds, $microseconds]); + $elapsed = tv_interval ( $t0, [gettimeofday]); + $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); + +=head1 DESCRIPTION + +=begin original + +The C<Time::HiRes> module implements a Perl interface to the +C<usleep>, C<nanosleep>, 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<nanosleep>, C<ualarm>, +C<gettimeofday>, C<setitimer>/C<getitimer> ¥·¥¹¥Æ¥à¥³¡¼¥à¡¢¸À¤¤´¹¤¨¤ì¤Ð +¹âÀºÅ٤λþ¹ï¤È¥¿¥¤¥Þ¡¼¤Ø¤Î¤Ø¤Î Perl ¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤ò¼ÂÁõ¤·¤Þ¤¹¡£ +»È¤¤Êý¤Ë¤Ä¤¤¤Æ¤Ï²¼µ¤Î L</»ÈÍÑÎã> ¥»¥¯¥·¥ç¥ó¤È¥Æ¥¹¥È¡¦¥¹¥¯¥ê¥×¥È¤ò +¤´Í÷¤¯¤À¤µ¤¤¡¨´ð¤Ë¤Ê¤Ã¤Æ¤¤¤ëC<nanosleep> ¤¢¤ë¤¤¤Ï C<usleep>, C<ualarm>, +C<gettimeofday>, ¤½¤·¤Æ 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()>, +C<select()>, and C<poll>, you don't get C<Time::HiRes::usleep()>, +C<Time::HiRes::nanosleep()>, 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()> ¤ä°ú¿ô°ì¤Ä¤Î·Á¤Ç¤Î C<tv_interval()> ¤Ï»È¤¨¤Þ¤»¤ó¡£ +¤¢¤Ê¤¿¤Î¥·¥¹¥Æ¥à¤Ë C<nanosleep()>, C<usleep()>, ¤½¤·¤Æ C<select()>, C<poll> ¤Î +Á´¤Æ¤¬¤Ê¤±¤ì¤Ð¡¢C<Time::HiRes::usleep()>, C<Time::HiRes::nanosleep()>, +C<Time::HiRes::sleep()> ¤Ï»È¤¨¤Þ¤»¤ó¡£ +¤¢¤Ê¤¿¤Î¥·¥¹¥Æ¥à¤Ë C<ualarm()> ¤È 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 not portable, +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. + +=end original + +¤¢¤Ê¤¿¤Î 1 Éðʲ¼¤Î sleep ¤¬ C<usleep()> ¤Ç¤Ï¤Ê¤¯ C<nanosleep()> ¤Ç +¼ÂÁõ¤µ¤ì¤Æ¤¤¤ì¤Ð¡¢ +C<nanosleep()> ¤Ï¥·¥°¥Ê¥ë¤ò»È¤ï¤Ê¤¤¤Î¤Ç¡¢1 Éðʲ¼¤Î sleep ¤È¥·¥°¥Ê¥ë¤ò +º®ºß¤µ¤»¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£ +¤·¤«¤·¤³¤ì¤Ï°Ü¿¢À¤ò·ç¤¤Þ¤¹¡£ +¤½¤·¤Æ¤Þ¤ººÇ½é¤Ë nanosleep ¤ò»ý¤Ã¤Æ¤¤¤ë¤Î¤«¡¢C<&Time::HiRes::d_nanosleep> ¤Î +Ãͤ¬ true ¤Ç¤¢¤ë¤«¥Á¥§¥Ã¥¯¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ +¤½¤ì¤«¤éÆÃͤʤ³¤È¤¬¤Ê¤¤¤«¿µ½Å¤Ë C<nanosleep()> C API +¥É¥¥å¥á¥ó¥È¤òÆɤޤʤ±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£ + +=begin original + +If you are using C<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. + +=end original + +sleep ¤È¥·¥°¥Ê¥ë¤òº®ºß¤µ¤»¤ë°Ê³°¤Î¤¿¤á¤Ë C<nanosleep> ¤ò»È¤¦¤È¡¢ +Perl ¤¬¥Ê¥ÎÉäÎÀµ³Î¤µ¤òÍ׵ᤵ¤ì¤ë»Å»ö¤Î¤¿¤á¤Ë»È¤¦¤Ù¤¥Ä¡¼¥ë¤Ç¤¢¤ë¤« +¤È¤¤¤¦µ¿Ì䤬¤¢¤ê¤Þ¤¹¡£ + +=begin original + +Remember that unless you are working on a I<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 +I<wallclock time> and process time (in UNIX-like systems the sum of +I<user> and I<system> times). Any attempt to sleep for X seconds will +most probably end up sleeping B<more> than that, but don't be surpised +if you end up sleeping slightly B<less>. + +=end original + +Remember that unless you are working on a I<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 +I<wallclock time> and process time (in UNIX-like systems the sum of +I<user> and I<system> times). Any attempt to sleep for X seconds will +most probably end up sleeping B<more> than that, but don't be surpised +if you end up sleeping slightly B<less>. +(TBT) + +=begin original + +The following functions can be imported from this module. +No functions are exported by default. + +=end original + +¤³¤Î¥â¥¸¥å¡¼¥ë¤«¤é°Ê²¼¤Î´Ø¿ô¤ò¥¤¥ó¥Ý¡¼¥È¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£ +¥Ç¥Õ¥©¥ë¥È¤Ç¥¨¥¯¥¹¥Ý¡¼¥È¤µ¤ì¤ë´Ø¿ô¤Ï¤¢¤ê¤Þ¤»¤ó¡£ + +=over 4 + +=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 + +ÇÛÎó¥³¥ó¥Æ¥¥¹¥È¤Ç¤Ï¥¨¥Ý¥Ã¥¯¤«¤é¤ÎÉäȥޥ¤¥¯¥íÉÃÆó¤Ä¤ÎÍ×ÁǤÎÇÛÎó¤òÊÖ¤·¤Þ¤¹¡£ +¥¹¥«¥é¡¼¡¦¥³¥ó¥Æ¥¥¹¥È¤Ç¤Ï¡¢C<Time::HiRes::time()> ¤Î¤è¤¦¤ËÉäò +ÉâÆ°¾®¿ôÅÀ¿ô¤ÇÊÖ¤·¤Þ¤¹¡Ê²¼µ»²¾È¡Ë¡£ + +=item usleep ( $useconds ) + +=begin original + +Sleeps for the number of microseconds (millionths of a second) +specified. Returns the number of microseconds actually slept. +Can sleep for more than one second, unlike the C<usleep> system call. +Can also sleep for zero seconds, which often works like a I<thread yield>. +See also C<Time::HiRes::usleep()>, C<Time::HiRes::sleep()>, and +C<Time::HiRes::clock_nanosleep()>. + +=end original + +»ØÄꤵ¤ì¤¿¥Þ¥¤¥¯¥íÉÃ(100 Ëüʬ¤Î 1 ÉÃ)¿ô¡¢sleep ¤·¤Þ¤¹¡£ +¼ÂºÝ¤Ë sleep ¤·¤¿¥Þ¥¤¥¯¥íÉÿô¤òÊÖ¤·¤Þ¤¹¡£ +C<usleep> ¥·¥¹¥Æ¥à¡¦¥³¡¼¥ë¤È¤Ï°ã¤¤¡¢1 Éðʾå sleep ¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£ +0 ÉÃ¥¹¥ê¡¼¥×¤¹¤ë¤³¤È¤â¤Ç¤¤Þ¤¹; ¤·¤Ð¤·¤Ð +I<¥¹¥ì¥Ã¥É°Ñ¾ù> (thread yield) ¤Î¤è¤¦¤ËƯ¤¤Þ¤¹¡£ +C<Time::HiRes::usleep()>, C<Time::HiRes::sleep()>, +C<Time::HiRes::clock_nanosleep()> +¤â¤´Í÷¤¯¤À¤µ¤¤¡£ + +=begin original + +Do not expect usleep() to be exact down to one microsecond. + +=end original + +usleep() ¤¬ 1 ¥Þ¥¤¥¯¥íÉÃñ°Ì¤ÇÀµ³Î¤ÈÁÛÄꤷ¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£ + +=item nanosleep ( $nanoseconds ) + +=begin original + +Sleeps for the number of nanoseconds (1e9ths of a second) specified. +Returns the number of nanoseconds actually slept (accurate only to +microseconds, the nearest thousand of them). Can sleep for more than +one second. Can also sleep for zero seconds, which often works like +a I<thread yield>. See also C<Time::HiRes::sleep()>, +C<Time::HiRes::usleep()>, and C<Time::HiRes::clock_nanosleep()>. + +=end original + +Sleeps for the number of nanoseconds (1e9ths of a second) specified. +Returns the number of nanoseconds actually slept (accurate only to +microseconds, the nearest thousand of them). Can sleep for more than +one second. Can also sleep for zero seconds, which often works like +a I<thread yield>. See also C<Time::HiRes::sleep()>, +C<Time::HiRes::usleep()>, and C<Time::HiRes::clock_nanosleep()>. +(TBT) + +=begin original + +Do not expect nanosleep() to be exact down to one nanosecond. +Getting even accuracy of one thousand nanoseconds is good. + +=end original + +Do not expect nanosleep() to be exact down to one nanosecond. +Getting even accuracy of one thousand nanoseconds is good. +(TBT) + +=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> ¤Î¤è¤¦¤ÊÆ°¤¤ò¤·¤Þ¤¹¡£ + +=begin original + +Returns the remaining time in the alarm in microseconds, or C<undef> +if an error occurred. + +=end original + +Returns the remaining time in the alarm in microseconds, or C<undef> +if an error occurred. +(TBT) + +=begin original + +ualarm(0) will cancel an outstanding ualarm(). + +=end original + +ualarm(0) will cancel an outstanding ualarm(). +(TBT) + +=begin original + +Note that the interaction between alarms and sleeps is unspecified. + +=end original + +¥¢¥é¡¼¥à¤È¥¹¥ê¡¼¥×¤ÎÁê¸ßºîÍѤÏ̤µ¬Äê¤Ç¤¢¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ + +=item tv_interval + +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 + +Æó¤Ä¤Î»þ¹ï¤Î»þ´Ö¤òÉâÆ°¾®¿ôÅÀ¤ÎÉÿô¤òÊÖ¤·¤Þ¤¹¡£ +Æó¤Ä¤Î»þ¹ï¤Ï 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. See also L</clock_getres>, if available +in your system. + +=end original + +B<Ãí°Õ 1>: ¤³¤Î¹âÀºÅ٤Πtime ¤Ï¡¢¤¢¤Ê¤¿¤Î¥×¥é¥Ã¥È¥Û¡¼¥à¤¬¥³¥¢¤Î C<time()> ¤ò +ÆÀ¤ë¤¿¤á¤Ë¡¢¤è¤ê¹âÀºÅ٤λþ¹ï¤òÀÚ¤ê¾å¤²¤¿¤ê¡¢ÀÚ¤ê¼Î¤Æ¤¿¤ê¡¢°ìÈֶᤤÉÃ¤Ë +¤¹¤ë¤Î¤¤¤º¤ì¤«¤Ë¤è¤Ã¤Æ¡¢¥³¥¢¤Î C<time()> ¤è¤ê¤â¿¤«¤Ã¤¿¤ê¡¢¾¯¤Ê¤«¤Ã¤¿¤ê +¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£ +¤·¤«¤·ÅöÁ³¡¢¤½¤Îº¹¤Ï 0.5 Éäò±Û¤¨¤ë¤³¤È¤Ï¤¢¤ê¤¨¤Þ¤»¤ó¡£ +¥·¥¹¥Æ¥à¤ÇÍøÍѲÄǽ¤Ê¤é¡¢L</clock_getres> ¤â»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ + +=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 the 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 ¤Ç¤Î¥Ç¥Õ¥©¥ë¥È¤ÎÉâÆ°¾®¿ôÅÀ¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤È¥¨¥Ý¥Ã¥¯¤«¤é¤ÎÉÿô¤¬ +¤¢¤¤¤Þ¤Ã¤ÆÌÀ¤é¤«¤Ê¥Ð¥°¤òºî¤ê½Ð¤·¤Þ¤¹: C<Time::HiRes::time()> ¤ÎÃͤò +½ÐÎϤ¹¤ë¤È¡¢Êݾڤµ¤ì¤¿ 6 ·å(¥Þ¥¤¥¯¥íÉÃ)¤Ç¤Ï¤Ê¤¯ 5 ·å¤Î¿ô»ú¤·¤«ÆÀ¤ë¤³¤È¤¬ +¤Ç¤¤Þ¤»¤ó¡£ +¤´¿´Çۤʤ¯¡£ +¥Þ¥¤¥¯¥íÉäϸºß¤·¤Þ¤¹(¤â¤Á¤í¤ó¤¢¤Ê¤¿¤Î +¥×¥é¥Ã¥È¥Û¡¼¥à¤¬¡¢¤½¤Î¤è¤¦¤ÊγÅÙ¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¤â¤Î¤ÈÁÛÄꤷ¤Æ¤¤¤Þ¤¹)¡£ +²¿¤¬µ¯¤¤Æ¤¤¤ë¤«¤È¤¤¤¨¤Ð¡¢Perl ¤ÎÉâÆ°¾®¿ôÅÀ¤Î¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤Ç¤Ï +15 ·å¤Î¿ô»ú¤·¤«½ÐÎϤ·¤Þ¤»¤ó¡£ +¤³¤Î¾ì¹ç¡¢¾®¿ôÅÀ¤ÎÁ°¤Ë 0 ·å¤Î¿ô»ú¤¬¤¢¤ê¡¢ +¤½¤Î¸å¤í¤Ë 5 ·å¤¢¤ê¤Þ¤¹¡£ +¥Þ¥¤¥¯¥íÉäò¸«¤ë¤¿¤á¤Ë¤Ï C<"%.6f"> ¤Ç C<printf>/C<sprintf> ¤Î +¤É¤Á¤é¤«¤ò»È¤¦¤«¡¢¥ê¥¹¥È¡¦¥³¥ó¥Æ¥¥¹¥È¤Ç C<gettimeofday()> ¤ò +»È¤¦¤³¤È¤¬¤Ç¤¤Þ¤¹¡£ +¤³¤Î¾ì¹ç¤Ë¤Ï¡¢Éäȥޥ¤¥¯¥íÉäÎ2¤Ä¤òÊ̤ÎÃͤȤ·¤ÆÍ¿¤¨¤Æ¤¯¤ì¤Þ¤¹¡£ + +=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> ¤ò +ÃÖ¤´¹¤¨¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹;²¼µ¤Î L</»ÈÍÑÎã> ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ + +=begin original + +Note that the interaction between alarms and sleeps is unspecified. + +=end original + +¥¢¥é¡¼¥à¤È¥¹¥ê¡¼¥×¤ÎÁê¸ßºîÍѤÏ̤µ¬Äê¤Ç¤¢¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ + +=item alarm ( $floating_seconds [, $interval_floating_seconds ] ) + +=begin original + +The C<SIGALRM> signal is sent after the specified number of seconds. +Implemented using C<setitimer()> if available, C<ualarm()> if not. +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<setitimer()> ¤¬¤¢¤ì¤Ð¤³¤ì¤ò»È¤¤¡¢¤Ê¤±¤ì¤Ð C<ualarm()> ¤ò»È¤Ã¤Æ +¼ÂÁõ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ +C<$interval_floating_seconds> °ú¿ô¤Ï +¥ª¥×¥·¥ç¥ó¤Ç»ØÄꤵ¤ì¤Ê¤¤¤È 0 ¤Ë¤Ê¤ê¤Þ¤¹¡£ +¤½¤Î·ë²Ì¡¢C<alarm()> ¤Î¤è¤¦¤ÊÆ°¤¤Ë¤Ê¤ê¤Þ¤¹¡£ +¤³¤Î´Ø¿ô¤Ï¥¤¥ó¥Ý¡¼¥È¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£ +¤½¤Î·ë²Ì¡¢Perl ¤Î¥³¥¢¤ÇÄ󶡤µ¤ì¤ëº¹¤·¹þ¤ß¼°¤Ë C<alarm> ¤ò +ÃÖ¤´¹¤¨¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹; ²¼µ¤Î L</»ÈÍÑÎã> ¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ + +=begin original + +Returns the remaining time in the alarm in seconds, or C<undef> +if an error occurred. + +=end original + +Returns the remaining time in the alarm in seconds, or C<undef> +if an error occurred. +(TBT) + +=begin original + +B<NOTE 1>: With some combinations of operating systems and Perl +releases C<SIGALRM> restarts C<select()>, instead of interrupting 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()> ¤ò¤¹¤ë¤È¡¢C<alarm()> ¤Ë»ØÄꤷ¤¿ +»þ´ÖÄ̤ê¤Ë¤Ç¤Ï¤Ê¤¯¡¢ +C<alarm()> ¤È C<select()> ¤Ë»ØÄꤵ¤ì¤¿»þ´Ö¤Î¹ç·×¤¬³Ý¤«¤ë¤«¤â +¤·¤ì¤Ê¤¤¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£ + +=begin original + +Note that the interaction between alarms and sleeps is unspecified. + +=end original + +¥¢¥é¡¼¥à¤È¥¹¥ê¡¼¥×¤ÎÁê¸ßºîÍѤÏ̤µ¬Äê¤Ç¤¢¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ + +=item setitimer ( $which, $floating_seconds [, $interval_floating_seconds ] ) + +=begin original + +Start up an interval timer: after a certain time, a signal ($which) arrives, +and more signals may keep arriving at certain intervals. To disable +an "itimer", 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 + +¥¤¥ó¥¿¡¼¥Ð¥ë¡¦¥¿¥¤¥Þ¡¼¤ò³«»Ï¤µ¤»¤Þ¤¹; °ìÄê¤Î»þ´Ö¸å¡¢¥·¥°¥Ê¥ë ($which) ¤¬ÆϤ¡¢ +¤¢¤ë´Ö³Ö¤Ç¥·¥°¥Ê¥ë¤¬ÆϤ³¤±¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ +"itimer" ¤ò»ß¤á¤ë¤Ë¤Ï¡¢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 (signals) 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 only Solaris seems to +have C<ITIMER_REALPROF> (which is used to profile multithreaded programs). +Win32 unfortunately does not haveinterval timers. + +=end original + +Ä̾ﻰ¤Ä¤¢¤ë¤¤¤Ï»Í¤Ä¤Î¥¤¥ó¥¿¡¼¥Ð¥ë¡¦¥¿¥¤¥Þ¡¼(¥·¥°¥Ê¥ë)¤¬ÍøÍѲÄǽ¤Ç¤¹: +C<$which> ¤Ï C<ITIMER_REAL>, C<ITIMER_VIRTUAL>, C<ITIMER_PROF>, +C<ITIMER_REALPROF> ¤Ë¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£ +¤É¤ì¤¬ÍøÍѤǤ¤ë¤«¤Ï°Ê²¼¤Î¤³¤È¤Ë°Í¸¤·¤Þ¤¹: ËÜÅö¤Î UNIX +¥×¥é¥Ã¥È¥Û¡¼¥à¤ÏÄ̾ïºÇ½é¤Î»°¤Ä¤ò»ý¤Ã¤Æ¤¤¤Þ¤¹¡£ +¤·¤«¤· Solaris ¤Ï C<ITIMER_REALPROF> ¤ò»ý¤Ã¤Æ¤¤¤ë¤è¤¦¤Ç¤¹ +(¤³¤ì¤Ï¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¤Ê¥×¥í¥°¥é¥à¤ò¥×¥í¥Õ¥¡¥¤¥ë¤¹¤ë¤¿¤á¤Ë»È¤ï¤ì¤Þ¤¹)¡£ +Win32 unfortunately does not haveinterval timers. +(TBT) + +=begin original + +C<ITIMER_REAL> results in C<alarm()>-like behaviour. 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. For example, it is unspecified which thread gets the signals. +See your C<setitimer()> documentation. + +=end original + +¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¤Ê¥×¥í¥°¥é¥à¤Ç¤Î¥¤¥ó¥¿¡¼¥Ð¥ë¡¦¥¿¥¤¥Þ¡¼¤Î°ÕÌ£¤Ï +¥·¥¹¥Æ¥à¤Ë¤è¤ê¤Þ¤¹¡£ +¤½¤·¤Æ¥·¥¹¥Æ¥à¤Ë¤è¤Ã¤Æ¤Ï¡¢¤µ¤é¤Ë¾¤Î +¥¤¥ó¥¿¡¼¥Ð¥ë¡¦¥¿¥¤¥Þ¡¼¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ +Î㤨¤Ð¡¢¥¹¥ì¥Ã¥É¤¬¤É¤Î¥¹¥ì¥Ã¥É¤¬¥·¥°¥Ê¥ë¤ò¼õ¿®¤¹¤ë¤«¤Ï̤µ¬Äê¤Ç¤¹¡£ +¤¢¤Ê¤¿¤Î C<setitimer()> ¤Î¥É¥¥å¥á¥ó¥È¤ò¤´Í÷¤¯¤À¤µ¤¤¡£ + +=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()> ¤ò»È¤Ã¤¿¤È¤¤ËÆþ¤ì¤¿¤â¤Î¤Ç¤¹¡£ + +=item clock_gettime ( $which ) + +=begin original + +Return as seconds the current value of the POSIX high resolution timer +specified by C<$which>. All implementations that support POSIX high +resolution timers are supposed to support at least the C<$which> value +of C<CLOCK_REALTIME>, which is supposed to return results close to the +results of C<gettimeofday>, or the number of seconds since 00:00:00:00 +January 1, 1970 Greenwich Mean Time (GMT). Do not assume that +CLOCK_REALTIME is zero, it might be one, or something else. +Another potentially useful (but not available everywhere) value is +C<CLOCK_MONOTONIC>, which guarantees a monotonically increasing time +value (unlike time() or gettimeofday(), which can be adjusted). +See your system documentation for other possibly supported values. + +=end original + +Return as seconds the current value of the POSIX high resolution timer +specified by C<$which>. All implementations that support POSIX high +resolution timers are supposed to support at least the C<$which> value +of C<CLOCK_REALTIME>, which is supposed to return results close to the +results of C<gettimeofday>, or the number of seconds since 00:00:00:00 +January 1, 1970 Greenwich Mean Time (GMT). Do not assume that +CLOCK_REALTIME is zero, it might be one, or something else. +Another potentially useful (but not available everywhere) value is +C<CLOCK_MONOTONIC>, which guarantees a monotonically increasing time +value (unlike time() or gettimeofday(), which can be adjusted). +See your system documentation for other possibly supported values. +(TBT) + +=item clock_getres ( $which ) + +=begin original + +Return as seconds the resolution of the POSIX high resolution timer +specified by C<$which>. All implementations that support POSIX high +resolution timers are supposed to support at least the C<$which> value +of C<CLOCK_REALTIME>, see L</clock_gettime>. + +=end original + +Return as seconds the resolution of the POSIX high resolution timer +specified by C<$which>. All implementations that support POSIX high +resolution timers are supposed to support at least the C<$which> value +of C<CLOCK_REALTIME>, see L</clock_gettime>. +(TBT) + +=item clock_nanosleep ( $which, $nanoseconds, $flags = 0) + +=begin original + +Sleeps for the number of nanoseconds (1e9ths of a second) specified. +Returns the number of nanoseconds actually slept. The $which is the +"clock id", as with clock_gettime() and clock_getres(). The flags +default to zero but C<TIMER_ABSTIME> can specified (must be exported +explicitly) which means that C<$nanoseconds> is not a time interval +(as is the default) but instead an absolute time. Can sleep for more +than one second. Can also sleep for zero seconds, which often works +like a I<thread yield>. See also C<Time::HiRes::sleep()>, +C<Time::HiRes::usleep()>, and C<Time::HiRes::nanosleep()>. + +=end original + +Sleeps for the number of nanoseconds (1e9ths of a second) specified. +Returns the number of nanoseconds actually slept. The $which is the +"clock id", as with clock_gettime() and clock_getres(). The flags +default to zero but C<TIMER_ABSTIME> can specified (must be exported +explicitly) which means that C<$nanoseconds> is not a time interval +(as is the default) but instead an absolute time. Can sleep for more +than one second. Can also sleep for zero seconds, which often works +like a I<thread yield>. See also C<Time::HiRes::sleep()>, +C<Time::HiRes::usleep()>, and C<Time::HiRes::nanosleep()>. +(TBT) + +=begin original + +Do not expect clock_nanosleep() to be exact down to one nanosecond. +Getting even accuracy of one thousand nanoseconds is good. + +=end original + +Do not expect clock_nanosleep() to be exact down to one nanosecond. +Getting even accuracy of one thousand nanoseconds is good. +(TBT) + +=item clock() + +=begin original + +Return as seconds the I<process time> (user + system time) spent by +the process since the first call to clock() (the definition is B<not> +"since the start of the process", though if you are lucky these times +may be quite close to each other, depending on the system). What this +means is that you probably need to store the result of your first call +to clock(), and subtract that value from the following results of clock(). + +=end original + +Return as seconds the I<process time> (user + system time) spent by +the process since the first call to clock() (the definition is B<not> +"since the start of the process", though if you are lucky these times +may be quite close to each other, depending on the system). What this +means is that you probably need to store the result of your first call +to clock(), and subtract that value from the following results of clock(). +(TBT) + +=begin original + +The time returned also includes the process times of the terminated +child processes for which wait() has been executed. This value is +somewhat like the second value returned by the times() of core Perl, +but not necessarily identical. Note that due to backward +compatibility limitations the returned value may wrap around at about +2147 seconds or at about 36 minutes. + +=end original + +The time returned also includes the process times of the terminated +child processes for which wait() has been executed. This value is +somewhat like the second value returned by the times() of core Perl, +but not necessarily identical. Note that due to backward +compatibility limitations the returned value may wrap around at about +2147 seconds or at about 36 minutes. +(TBT) + +=item stat + +=item stat FH + +=item stat EXPR + +=begin original + +As L<perlfunc/stat> but with the access/modify/change file timestamps +in subsecond resolution, if the operating system and the filesystem +both support such timestamps. To override the standard stat(): + +=end original + +As L<perlfunc/stat> but with the access/modify/change file timestamps +in subsecond resolution, if the operating system and the filesystem +both support such timestamps. To override the standard stat(): +(TBT) + + use Time::HiRes qw(stat); + +=begin original + +Test for the value of &Time::HiRes::d_hires_stat to find out whether +the operating system supports subsecond file timestamps: a value +larger than zero means yes. There are unfortunately no easy +ways to find out whether the filesystem supports such timestamps. +UNIX filesystems often do; NTFS does; FAT doesn't (FAT timestamp +granularity is B<two> seconds). + +=end original + +Test for the value of &Time::HiRes::d_hires_stat to find out whether +the operating system supports subsecond file timestamps: a value +larger than zero means yes. There are unfortunately no easy +ways to find out whether the filesystem supports such timestamps. +UNIX filesystems often do; NTFS does; FAT doesn't (FAT timestamp +granularity is B<two> seconds). +(TBT) + +=begin original + +A zero return value of &Time::HiRes::d_hires_stat means that +Time::HiRes::stat is a no-op passthrough for CORE::stat(), +and therefore the timestamps will stay integers. The same +thing will happen if the filesystem does not do subsecond timestamps, +even if the &Time::HiRes::d_hires_stat is non-zero. + +=end original + +A zero return value of &Time::HiRes::d_hires_stat means that +Time::HiRes::stat is a no-op passthrough for CORE::stat(), +and therefore the timestamps will stay integers. The same +thing will happen if the filesystem does not do subsecond timestamps, +even if the &Time::HiRes::d_hires_stat is non-zero. +(TBT) + +=begin original + +In any case do not expect nanosecond resolution, or even a microsecond +resolution. Also note that the modify/access timestamps might have +different resolutions, and that they need not be synchronized, e.g. +if the operations are + +=end original + +In any case do not expect nanosecond resolution, or even a microsecond +resolution. Also note that the modify/access timestamps might have +different resolutions, and that they need not be synchronized, e.g. +if the operations are +(TBT) + + write + stat # t1 + read + stat # t2 + +=begin original + +the access time stamp from t2 need not be greater-than the modify +time stamp from t1: it may be equal or I<less>. + +=end original + +the access time stamp from t2 need not be greater-than the modify +time stamp from t1: it may be equal or I<less>. +(TBT) + +=back + +=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); + # cancel that ualarm + ualarm(0); + +=end original + + # 2.5Éø塢¤½¤Î¸å¤Ï0.1¹Ô¤´¤È¤Ë¥·¥°¥Ê¥ë¡¦¥¢¥é¡¼¥à + ualarm(2_500_000, 100_000); + # ¤³¤Î ualarm ¤ò¥¥ã¥ó¥»¥ë + ualarm(0); + +=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 + + # ·Ð²á»þ´Ö¤Î·×¬ + # (Æó¤Ä¤Î gettimeofday ¤ÎÌá¤êÃͤò°ú¤¯¤³¤È¤Ë¤è¤Ã¤Æ¤â²Äǽ¤Ç¤¹) + $t0 = [gettimeofday]; + # ¤³¤³¤Ç²¿¤«½èÍý¤Î¸Ç¤Þ¤ê¤ò¼Â¹Ô + $t1 = [gettimeofday]; + # ¤µ¤é¤Ë½èÍý¤Î¸Ç¤Þ¤ê¤ò¼Â¹Ô + $t0_t1 = tv_interval $t0, $t1; + + $elapsed = tv_interval ($t0, [gettimeofday]); + $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 ¤òÉâÆ°¾®¿ôÅÀ¤Ç¤ÎÉ䬤狼¤ë + # ¤â¤Î¤ÇÃÖ¤´¹¤¨ + # + use Time::HiRes; + $now_fractions = Time::HiRes::time; + Time::HiRes::sleep (2.5); + Time::HiRes::alarm (10.6666666); + + use Time::HiRes qw ( time alarm sleep ); + $now_fractions = time; + 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 Éä´¤È¤Ë + # ¤ä¤Ã¤Æ¤¯¤ë¥¤¥ó¥¿¡¼¥Ð¥ë¥¿¥¤¥Þ¡¼¤òÁõÈ÷¤¹¤ë + + use Time::HiRes qw ( setitimer ITIMER_VIRTUAL time ); + + $SIG{VTALRM} = sub { print time, "\n" }; + setitimer(ITIMER_VIRTUAL, 10, 2.5); + + use Time::HiRes qw( clock_gettime clock_getres CLOCK_REALTIME ); + # Read the POSIX high resolution timer. + my $high = clock_getres(CLOCK_REALTIME); + # But how accurate we can be, really? + my $reso = clock_getres(CLOCK_REALTIME); + + use Time::HiRes qw( clock_nanosleep TIMER_ABSTIME ); + clock_nanosleep(CLOCK_REALTIME, 1e6); + clock_nanosleep(CLOCK_REALTIME, 2e9, TIMER_ABSTIME); + + use Time::HiRes qw( clock ); + my $clock0 = clock(); + ... # Do something. + my $clock1 = clock(); + my $clockd = $clock1 - $clock0; + + use Time::HiRes qw( stat ); + my ($atime, $mtime, $ctime) = (stat("istics"))[8, 9, 10]; + +=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 (*)(pTHX_ UV ret[2]) + +=end original + + ´Ø¿ô̾ C¥×¥í¥È¥¿¥¤¥× + --------------- ---------------------- + Time::NVtime double (*)() + Time::U2time void (*)(pTHX_ 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 Win32 and +VMS have emulations for it.) + +=end original + +´Ø¿ô¤ÏξÊý¤È¤â(C<gettimeofday> ¤Î¤è¤¦¤Ê)Ʊ¤¸¾ðÊó¤òÊÖ¤·¤Þ¤¹¡£ +¤·¤«¤·¤½¤Îɽ¸½¤¬°ã¤¤¤Þ¤¹¡£C<NVtime> ¤È C<U2time> ¤È¤¤¤¦Ì¾Á°¤Ï¼ç¤Ë +¥ª¥Ú¥ì¡¼¥Æ¥£¥ó¥°¡¦¥·¥¹¥Æ¥à¤Ë°Í¸¤·¤Æ¤¤¤Ê¤¤¤¿¤á¤ËÁªÂò¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ +(Win32 ¤ä VMS ¤Î¤è¤¦¤Ë¤¤¤¯¤Ä¤«¤Î¥×¥é¥Ã¥È¥Û¡¼¥à¤Ç¤Ï¤½¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤ò +È÷¤¨¤Æ¤¤¤Þ¤¹¤¬¡¢C<gettimeofday> ¤Ï Unix Ã濴Ū¤Ç¤¹¡£) + +=begin original + +Here is an example of using C<NVtime> from C: + +=end original + +C ¤«¤é C<NVtime> ¤ò»È¤Ã¤¿¤È¤¤ÎÎã¤ò°Ê²¼¤Ë¼¨¤·¤Þ¤¹: + + double (*myNVtime)(); /* Returns -1 on failure. */ + SV **svp = hv_fetch(PL_modglobal, "Time::NVtime", 12, 0); + if (!svp) croak("Time::HiRes is required"); + if (!SvIOK(*svp)) croak("Time::NVtime isn't a function pointer"); + myNVtime = INT2PTR(double(*)(), SvIV(*svp)); + printf("The current time is: %f\n", (*myNVtime)()); + +=head1 DIAGNOSTICS + +=head2 useconds or interval more than ... + +=begin original + +In ualarm() you tried to use number of microseconds or interval (also +in microseconds) more than 1_000_000 and setitimer() is not available +in your system to emulate that case. + +=end original + +In ualarm() you tried to use number of microseconds or interval (also +in microseconds) more than 1_000_000 and setitimer() is not available +in your system to emulate that case. +(TBT) + +=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 + +²¿¤«¤Ò¤É¤¤¾ã³²¤¬¤ª¤¤Þ¤·¤¿ -- ¥Þ¥¤¥Ê¥¹¤Ë¤Ê¤ë¤Ï¤º¤Î¤Ê¤¤¥Þ¥¤¥¯¥íÉÿô¤Ï +¥Þ¥¤¥Ê¥¹¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¤¤Þ¤·¤¿¡£ +¥³¥ó¥Ñ¥¤¥é¤¬²õ¤ì¤Æ¤¤¤ë¤Î¤«¤â? + +=head2 useconds or uinterval equal to or more than 1000000 + +=begin original + +In some platforms it is not possible to get an alarm with subsecond +resolution and later than one second. + +=end original + +In some platforms it is not possible to get an alarm with subsecond +resolution and later than one second. +(TBT) + +=head2 unimplemented in this platform + +=begin original + +Some calls simply aren't available, real or emulated, on every platform. + +=end original + +°ìÉô¤Î¸Æ¤Ó½Ð¤·¤Ï¡¢¼Âʪ¤È¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤È¤Ë´Ø¤ï¤é¤º¡¢Á´¤Æ¤Î +¥×¥é¥Ã¥È¥Õ¥©¡¼¥à¤ÇÍøÍѲÄǽ¤È¤¤¤¦¤ï¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£ + +=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ÉÃÃÙ¤¤»þ´Ö¤òÊó¹ð¤¹¤ë¤«¤â¤·¤ì¤Ê¤¤¤È¤¤¤¦ +¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£ + +=begin original + +Adjusting the system clock (either manually or by services like ntp) +may cause problems, especially for long running programs that assume +a monotonously increasing time (note that all platforms do not adjust +time as gracefully as UNIX ntp does). For example in Win32 (and derived +platforms like Cygwin and MinGW) the Time::HiRes::time() may temporarily +drift off from the system clock (and the original time()) by up to 0.5 +seconds. Time::HiRes will notice this eventually and recalibrate. +Note that since Time::HiRes 1.77 the clock_gettime(CLOCK_MONOTONIC) +might help in this (in case your system supports CLOCK_MONOTONIC). + +=end original + +Adjusting the system clock (either manually or by services like ntp) +may cause problems, especially for long running programs that assume +a monotonously increasing time (note that all platforms do not adjust +time as gracefully as UNIX ntp does). For example in Win32 (and derived +platforms like Cygwin and MinGW) the Time::HiRes::time() may temporarily +drift off from the system clock (and the original time()) by up to 0.5 +seconds. Time::HiRes will notice this eventually and recalibrate. +Note that since Time::HiRes 1.77 the clock_gettime(CLOCK_MONOTONIC) +might help in this (in case your system supports CLOCK_MONOTONIC). +(TBT) + +=begin original + +Some systems have APIs but not implementations: for example QNX and Haiku +have the interval timer APIs but not the functionality. + +=end original + +Some systems have APIs but not implementations: for example QNX and Haiku +have the interval timer APIs but not the functionality. +(TBT) + +=head1 SEE ALSO + +=begin original + +Perl modules L<BSD::Resource>, L<Time::TAI64>. + +=end original + +Perl ¥â¥¸¥å¡¼¥ë L<BSD::Resource>, L<Time::TAI64>¡£ + +=begin original + +Your system documentation for C<clock>, C<clock_gettime>, +C<clock_getres>, C<clock_nanosleep>, C<clock_settime>, C<getitimer>, +C<gettimeofday>, C<setitimer>, C<sleep>, C<stat>, C<ualarm>. + +=end original + +¥·¥¹¥Æ¥à¤Î C<clock>, C<clock_gettime>, +C<clock_getres>, C<clock_nanosleep>, C<clock_settime>, C<getitimer>, +C<gettimeofday>, C<setitimer>, C<sleep>, C<stat>, C<ualarm> ¤Îʸ½ñ¡£ + +=head1 AUTHORS + +D. Wegscheid <wegsc****@whirl*****> +R. Schertler <roder****@argon*****> +J. Hietaniemi <jhi****@iki*****> +G. Aas <gisle****@aas*****> + +=head1 COPYRIGHT AND LICENSE + +Copyright (c) 1996-2002 Douglas E. Wegscheid. All rights reserved. + +Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Jarkko Hietaniemi. +All rights reserved. + +This program is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +=begin meta + +Translate: Àî¹ç¹§Åµ <GCD00****@nifty*****> (1.55) +Update: SHIRAKATA Kentaro <argra****@ub32*****> (1.9719-) +Status: in progress + +=end meta + +=cut +