Beefy Boxes and Bandwidth Generously Provided by pair Networks chromatic writing perl on a camel
There's more than one way to do things
 
PerlMonks  

Re: Benchmarking A DB-Intensive Script

by idle (Friar)
on Mar 14, 2006 at 02:32 UTC ( [id://536488]=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 Benchmarking A DB-Intensive Script

Hi, you can use Time::HiRes, like this:
use Time::HiRes qw(gettimeofday); my $start=gettimeofday; next part of code... my $next=gettimeofday; printf "time spended %.4f" ,($next-$start); next part of code... my $next_1=gettimeofday; printf "time spended %.4f" ,($next_1-$next);
to see where exactly it is slow.

Replies are listed 'Best First'.
Re^2: Benchmarking A DB-Intensive Script
by bernanke01 (Beadle) on Mar 14, 2006 at 15:02 UTC

    Hi, I was thinking of something like this using Benchmark as well, but then how do I add the values across many (say 10k) iterations of the loop? I didn't see a way to do that with either Benchmark or Time::HiRes -- did I miss it?

      Take a look at Benchmark::Timer. You can wrap a start/stop pairing around a piece of code and it accumulates the iterations and average the times taken for you. You can also run several different and overlapping pairs concurrently, which makes it easy to start with a course granularity and then home in onto those parts where you need finer granularity.

      It allows you to get finer granularity than one of the per subroutine profilers without resorting to the time expensive per line profilers.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://536488]
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.