Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Benchmark Wrapper

by thabenksta (Pilgrim)
on Apr 04, 2001 at 19:56 UTC ( [id://69858]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Benchmark Wrapper

Get the time before the loop, and then the time after the loop, and compare.

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

Replies are listed 'Best First'.
Re: Re: Benchmark Wrapper
by qball (Beadle) on Apr 04, 2001 at 20:00 UTC
    That was my first concept, but I'd like to somehow put it in a sub routine so I don't have to add so many lines to each report loop. Maybe I could just make the compare code a routine and call it within each report routine. Unless, of course, there's a better way.

    qball~"I have node idea?!"

      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';
        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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://69858]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.