|
On my box at home (A), usleep will sleep (approximately) the number of microseconds you pass to it. (requested + 0-2000us)
On another box (B), it is all over the place. Some times +10000, sometimes +20000!
I can deal with a 2000us wiggle, but a I can't handle the usleep instability on machine B.
And, I am having a hell of a time trying to figure out its source.
Originally I had Time:HiRes version 1.66 at home on box A and box B had 1.38 (from the RH RPM). I thought that was the problem so I installed 1.66 from CPAN onto box B. But 1.38 and 1.66 have the same behavior on machine B ...
machine A: 1CPU Athlon with Fedora Core 3
machine B: looks like a 2CPU with HyperThreading on running RedHat Enterprise Linux WS
machine C, 2CPU with HyperThreading off running RH EL AS, has the same results as B.
Something related to RedHat Enterprise Linux? I doubt that it would be due to multi CPUs.
help,
Christopher
################################################################################
#-------------------------------------------------------------------------------
hires_test.pl
#-------------------------------------------------------------------------------
#!/usr/bin/perl -w
use warnings;
use strict;
use Time::HiRes qw(gettimeofday sleep usleep time);
print "Time::HiRes\n";
print "VERSION:" . Time::HiRes->VERSION . "\n\n";
print `uname -a` . "\n";
my $index = 1000;
print "usleep (usec)\n(requested == actual)\n";
while ( $index <= 40_000 ){
print "$index == " . Time::HiRes::usleep($index) . "\n";
$index += 1000;
}
print "\n\n";
$index = 0.001000;
print "sleep (sec)\n(requested == actual)\n";
while ( $index <= 0.0405 ){
print "$index == " . Time::HiRes::sleep($index) . "\n";
$index += 0.001;
}
exit;
#-------------------------------------------------------------------------------
machine A
#-------------------------------------------------------------------------------
Time::HiRes
VERSION:1.66
Linux **** 2.6.10-1.741_FC3 #1 Thu Jan 13 16:38:22 EST 2005 i686 athlon i386 GNU/Linux
usleep (usec)
(requested == actual)
1000 == 2348
2000 == 3944
3000 == 4987
4000 == 5990
5000 == 6992
6000 == 7980
7000 == 8985
8000 == 9963
9000 == 10981
10000 == 11983
11000 == 12984
12000 == 13981
13000 == 14988
14000 == 15990
15000 == 16982
16000 == 17987
17000 == 18989
18000 == 19979
19000 == 20987
20000 == 21983
21000 == 22979
22000 == 23987
23000 == 24981
24000 == 25988
25000 == 27055
26000 == 27904
27000 == 28964
28000 == 29954
29000 == 30979
30000 == 31979
31000 == 32966
32000 == 33977
33000 == 34978
34000 == 35984
35000 == 36978
36000 == 37977
37000 == 38977
38000 == 39977
39000 == 40978
40000 == 41967
sleep (sec)
(requested == actual)
0.001 == 0.0029
0.002 == 0.00398
0.003 == 0.004987
0.004 == 0.005988
0.005 == 0.006988
0.006 == 0.00802
0.007 == 0.008951
0.008 == 0.009986
0.009 == 0.010988
0.01 == 0.011987
0.011 == 0.012988
0.012 == 0.01398
0.013 == 0.014987
0.014 == 0.016016
0.015 == 0.016951
0.016 == 0.01798
0.017 == 0.018981
0.018 == 0.01998
0.019 == 0.020985
0.02 == 0.021986
0.021 == 0.022979
0.022 == 0.023986
0.023 == 0.024976
0.024 == 0.025986
0.025 == 0.026977
0.026 == 0.027984
0.027 == 0.028981
0.028 == 0.029961
0.029 == 0.030975
0.03 == 0.031948
0.031 == 0.032976
0.032 == 0.033974
0.033 == 0.034979
0.034 == 0.035964
0.035 == 0.036971
0.036 == 0.037975
0.037 == 0.038975
0.038 == 0.039982
0.039 == 0.040967
0.04 == 0.041976
#-------------------------------------------------------------------------------
machine B
#-------------------------------------------------------------------------------
Time::HiRes
VERSION:1.38
Linux **** 2.4.21-27.0.2.ELsmp #1 SMP Wed Jan 12 23:35:44 EST 2005 i686 i686 i386 GNU/Linux
usleep (usec)
(requested == actual)
1000 == 16799
2000 == 19946
3000 == 20013
4000 == 19946
5000 == 19980
6000 == 20005
7000 == 19982
8000 == 19973
9000 == 19981
10000 == 19962
11000 == 29982
12000 == 29995
13000 == 29958
14000 == 29994
15000 == 29984
16000 == 29982
17000 == 29997
18000 == 29964
19000 == 29980
20000 == 29981
21000 == 40021
22000 == 39907
23000 == 39976
24000 == 40009
25000 == 39913
26000 == 39996
27000 == 39997
28000 == 39872
29000 == 39990
30000 == 39930
31000 == 49968
32000 == 49956
33000 == 49973
34000 == 49993
35000 == 49980
36000 == 49973
37000 == 49952
38000 == 49984
39000 == 49985
40000 == 49973
sleep (sec)
(requested == actual)
0.001 == 0.019934
0.002 == 0.019998
0.003 == 0.019987
0.004 == 0.020042
0.005 == 0.019919
0.006 == 0.019972
0.007 == 0.019994
0.008 == 0.01998
0.009 == 0.019969
0.01 == 0.019971
0.011 == 0.030011
0.012 == 0.02996
0.013 == 0.029991
0.014 == 0.029958
0.015 == 0.030004
0.016 == 0.029987
0.017 == 0.029976
0.018 == 0.029925
0.019 == 0.030006
0.02 == 0.029951
0.021 == 0.039992
0.022 == 0.040002
0.023 == 0.039903
0.024 == 0.040005
0.025 == 0.039938
0.026 == 0.039966
0.027 == 0.039988
0.028 == 0.039985
0.029 == 0.039929
0.03 == 0.039984
0.031 == 0.04994
0.032 == 0.049978
0.033 == 0.049945
0.034 == 0.049982
0.035 == 0.049987
0.036 == 0.049972
0.037 == 0.049978
0.038 == 0.049998
0.039 == 0.049942
0.04 == 0.049978
#-------------------------------------------------------------------------------
machine B
#-------------------------------------------------------------------------------
Time::HiRes
VERSION:1.66
Linux **** 2.4.21-27.0.2.ELsmp #1 SMP Wed Jan 12 23:35:44 EST 2005 i686 i686 i386 GNU/Linux
usleep (usec)
(requested == actual)
1000 == 15854
2000 == 19939
3000 == 19971
4000 == 19949
5000 == 19988
6000 == 20001
7000 == 19947
8000 == 19992
9000 == 19970
10000 == 19988
11000 == 29955
12000 == 29984
13000 == 29978
14000 == 29944
15000 == 29988
16000 == 29984
17000 == 29951
18000 == 30014
19000 == 29929
20000 == 29953
21000 == 39999
22000 == 39943
23000 == 40009
24000 == 39936
25000 == 39962
26000 == 39954
27000 == 39994
28000 == 39976
29000 == 39932
30000 == 39967
31000 == 49959
32000 == 49923
33000 == 49968
34000 == 49965
35000 == 49968
36000 == 50005
37000 == 49908
38000 == 49961
39000 == 49950
40000 == 49990
sleep (sec)
(requested == actual)
0.001 == 0.019945
0.002 == 0.020002
0.003 == 0.019968
0.004 == 0.019985
0.005 == 0.019993
0.006 == 0.019974
0.007 == 0.019986
0.008 == 0.020003
0.009 == 0.019971
0.01 == 0.019971
0.011 == 0.029993
0.012 == 0.02998
0.013 == 0.029989
0.014 == 0.029984
0.015 == 0.030005
0.016 == 0.029949
0.017 == 0.030052
0.018 == 0.029874
0.019 == 0.029999
0.02 == 0.029974
0.021 == 0.039991
0.022 == 0.039957
0.023 == 0.03998
0.024 == 0.039974
0.025 == 0.039976
0.026 == 0.039951
0.027 == 0.03998
0.028 == 0.039994
0.029 == 0.039952
0.03 == 0.039976
0.031 == 0.049965
0.032 == 0.049999
0.033 == 0.049979
0.034 == 0.049948
0.035 == 0.049969
0.036 == 0.049979
0.037 == 0.049988
0.038 == 0.049942
0.039 == 0.049968
0.04 == 0.049934
|