Hi fellow monks,
I'm having a problem with the sleep function in the Time::HiRes module in another script of mine so I quickly wrote the code below to test and this is what happens when I run it with sleep set to (0.001):use strict; use warnings; use Time::HiRes qw(sleep gettimeofday tv_interval); my $test = 0; my $match = 0; while ( $test < 2000 ) { &sleepy($test); $test++; } print "A match occurred $match times"; sub sleepy { my $count = shift; my $time = gettimeofday; sleep(0.001); # Sleep here to ensure unique time my $hitime = gettimeofday; if ( $time == $hitime ) { $match++; } }
In reply to Time::HiRes sleep does not always work by tone
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |