Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

mod_perl 2.0 and Benchmark and Time::Hires results in multiples of .015625

by mbeast (Beadle)
on Oct 22, 2004 at 14:13 UTC ( [id://401480] : perlquestion . print w/replies, xml ) Need Help??

mbeast has asked for the wisdom of the Perl Monks concerning the following question:

I have been tracking the time it takes to execute my scripts using Benchmark. Recently I converted from using mod_perl Registry to making the script a handler. My results when using Registry were random, however as a handler my results are always a multiple of .01562500.
use Benchmark; use Time::HiRes qw(gettimeofday tv_interval); sub handler { my $start_time = new Benchmark; some subs; my $end_time = new Benchmark; my $compute_time = timediff($end_time, $start_time); }
I've also tried this:
use Time::HiRes qw(gettimeofday tv_interval); sub handler { my $start_time = [ gettimeofday ]; some subs; my $end_time = [ gettimeofday ]; my $compute_time = tv_interval($start_time_t,$end_time_t); }
with the same results. (0.01562500, 0.03125000, 0.04687500,...)

EDIT for simonm: Win2000, Perl version v5.8.4, Apache/2.0.50, mod_perl 1.9916, Benchmark 1.06, Time::HiRes 1.59

Replies are listed 'Best First'.
Re: mod_perl 2.0 and Benchmark and Time::Hires results in multiples of .015625
by iburrell (Chaplain) on Oct 22, 2004 at 16:51 UTC
    On Windows, Time::HiRes doesn't have very good resolution. 1/64 s sounds about right. The API it uses has the poor resolution.
Re: mod_perl 2.0 and Benchmark and Time::Hires results in multiples of .015625
by simonm (Vicar) on Oct 22, 2004 at 14:49 UTC
    I'm not sure what the problem is, but I found it interesting that the interval was exactly 1/64th of a second.

    Is this a Unix platform, Windows, or something more obscure?