saneel has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I am using Time:HiRes module. I just measuring the before and after time as shown in the script below. However, in many cases the "after time" comes out less than "before time", when I run it on Windows with multi-core CPU's. I don't get this when I am running the below script on a VM which has Linux with only one processor allocated to it. Why could this be happening?
#!/usr/bin/perl -w use Time::HiRes; $count = 1000000; print "\nStarting loop\n"; for ($c = $count; $c >= 1; $c--) { $t3 = 0; $t4 =0; $t5 = 0; #print "\n"; #print "t3: "; printf "%.2f\n",$t3; #print "t4: "; printf "%.2f\n",$t4; #print "\n"; $t3 = Time::HiRes::time(); $t4 = Time::HiRes::time(); $t5 = $t4-$t3; #print "t5: "; printf "%.6f\n",$t5; if($t5<=0) { print"\n Value negative in count: $c"; print "\n t3: "; printf "%.6f",$t3; print "\n t4: "; printf "%.6f\n",$t4; print "\n Negative or zero value: $t5"; } } print "\nEnd of loop\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: negative elapsed time? (versions?)
by BrowserUk (Patriarch) on Aug 08, 2011 at 15:18 UTC | |
by saneel (Initiate) on Aug 08, 2011 at 15:31 UTC | |
by BrowserUk (Patriarch) on Aug 08, 2011 at 15:35 UTC | |
by saneel (Initiate) on Aug 08, 2011 at 15:38 UTC | |
by BrowserUk (Patriarch) on Aug 08, 2011 at 15:44 UTC | |
Re: negative elapsed time?
by FunkyMonk (Chancellor) on Aug 08, 2011 at 15:09 UTC | |
by saneel (Initiate) on Aug 08, 2011 at 15:14 UTC | |
Re: negative elapsed time?
by Marshall (Canon) on Aug 08, 2011 at 15:40 UTC | |
by BrowserUk (Patriarch) on Aug 08, 2011 at 18:43 UTC | |
by BrowserUk (Patriarch) on Aug 08, 2011 at 15:48 UTC | |
by saneel (Initiate) on Aug 08, 2011 at 15:44 UTC | |
by BrowserUk (Patriarch) on Aug 08, 2011 at 22:55 UTC | |
Re: negative elapsed time?
by zentara (Archbishop) on Aug 08, 2011 at 14:58 UTC |
Back to
Seekers of Perl Wisdom