in reply to Re: Re: Benchmark Wrapper
in thread Benchmark Wrapper

You could write a subroutine to put before and after the loop. Before the loop, you could have it return the time, and after the loop feed it that time and return the difference. That's the only way I can think of.

my $name = 'Ben Kittrell'; $name=~s/^(.+)\s(.).+$/\L$1$2/g; my $nick = 'tha' . $name . 'sta';

Replies are listed 'Best First'.
Re: Re: Re: Re: Benchmark Wrapper
by Albannach (Monsignor) on Apr 05, 2001 at 00:26 UTC
    From the Benchmark docs for the new method:
    use Benchmark; $t0 = new Benchmark; # ... your code here ... $t1 = new Benchmark; $td = timediff($t1, $t0); print "the code took:",timestr($td),"\n";
    Update: A cheap example to help qball with his questions:
    use strict; use Benchmark; print "Starting..."; my $t0 = new Benchmark; # ... your code here ... sleep(3); my $t1 = new Benchmark; my $td = timediff($t1, $t0); print 'the code took:',timestr($td),"\n"; my $sec = timestr($td)+0; print "that's ",timestr($td)+0," seconds\n"; my $min = int($sec/60); $sec = $sec - $min*60; printf ("also known as %d:%02d", $min, $sec);

    --
    I'd like to be able to assign to an luser