in reply to Time::HiRes sleep does not always work
sub sleepy { my $count = shift; my $time = gettimeofday; sleep(0.0001); # Sleep here to ensure unique time my $hitime = gettimeofday; print $time - $hitime,' '; if ( $time == $hitime ) { $match++; } }
I think you are running into some real world factors affecting computers(desktops/laptops). Although we all like to assume that our little machines maintain atomic clock, laboratory quality, time; it's not true. A computer has a little imperfect crystal, that maintains it's time. The crystal is not even temperature stabilized, meaning your clock rate varies with temperature. It's not enough for us to notice, unless there is a bad failure, and the computer circuitry is designed to work with the variations, by using edges of clock waves for synchronization.
You also have the kernel's design to consider. There are different schedulers, and the one you would want to use would be the low-latency kernel, that audiophiles use. Otherwise, your kernel may decide to spend a few microseconds updating your display, rather than process your script.
Our computers seem like superfast machines to us, but in a true measure of time, they slog along like they were mired in molasses.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Time::HiRes sleep does not always work
by tone (Novice) on Aug 18, 2008 at 10:09 UTC | |
by zentara (Cardinal) on Aug 18, 2008 at 13:42 UTC |