And if you really want to follow a rapidly growing file (for instance some timing sensitive log without proper timestamps) with a lot finer time resolution than probably you appreciate the File-Tail module from CPAN. This modules adapts its sleep interval to the line-update frequency measured before. (Of course if you don't have control on the buffering at output side, this still won't be better.) An example:-s, --sleep-interval=S with -f, sleep for approximately S seconds (default 1.0) between ite +rations
# generate test log file in bash $ while true ; do echo $(( ++i )) ; sleep .1 ; done > test
# little File::Tail demo use Time::HiRes qw( gettimeofday ); use File::Tail; $| = 1; my $tail = File::Tail->new( name => './test', maxinterval => 0.1 ); my $usec; my $sec_since_epoch; my $line; while ( defined( $line = $tail->read() ) ) { ( $sec_since_epoch, $usec ) = gettimeofday(); printf "%d.%d\n", $sec_since_epoch, $usec; }
In reply to Re: Time::HiRes strange behavior
by rubasov
in thread Time::HiRes strange behavior
by golden.radish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |