in reply to Re: Opening file and checking for data
in thread Opening file and checking for data

In the Perl Cookbook recipe 3.9 'High-Resolution Timers' looks pretty useful for timing code - it uses the Time::HiRes module which comes standard in Perl 5.8:
use Time::HiRes qw(gettimeofday); $t0 = gettimeofday; ### your code here ### $t1 = gettimeofday; $elapsed = $t1 - $t0; # elapsed is a floating point value, representing the # number of seconds between $t0 and $t1
then do the same thing for the *other* way, and see which one takes the least amount of time.

Replies are listed 'Best First'.
Re: Re: Re: Opening file and checking for data
by tomhukins (Curate) on Jul 03, 2003 at 13:57 UTC

    If you want to benchmark your code, use Perl's Benchmark module. There's no need to reinvent it. Super Search should find numerous examples of how to use it.

    Update: I see you have already mentioned Benchmark. In future, I must read more carefully before repying. Bad me.