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

hi all

i'm looking for a snippet of code which would allow me to benchmarking my script... more simply put, i want to display the time it takes for my script to run... so i take the time at the end of the script minus the time at the beginning of the script...

i've tried looking at the 'snippets' section but it turned up a snippet which does it over iterations instead...

thanks
  • Comment on YA newbie question: benchmarking your scripts?

Replies are listed 'Best First'.
Re: YA newbie question: benchmarking your scripts?
by cjf (Parson) on May 24, 2002 at 02:13 UTC
Re: YA newbie question: benchmarking your scripts?
by joealba (Hermit) on May 24, 2002 at 03:10 UTC
    Check out this node for the Benchmark snippet you're looking for.

    Just remember that your most valid benchmarks come from multiple iterations, as you would get from the link cjf posted.
      thanks joealba! that's exactly what i'm looking for... thing is right now the script runs slow enough as it is and i figure 1 run though would be enough for my purposes... i do understand that you'd need to run several iterations for a proper benchmark but i guess once is sufficient for this script
        Ahh.. Now we see. :)

        You can use as many of those benchmarks as you want in one file, so don't be shy with them while you're trying to find the code that's crawling. Slap some in at the start and end of each of your reasonably-sized code blocks or loops.

        Code optimization -- it's an art. :)
Re: YA newbie question: benchmarking your scripts?
by redemption (Sexton) on May 24, 2002 at 02:23 UTC
    thanks turnstep... the snippet i found was also like this... but this only allows me to to benchmark if code if i pass it the code i want to run... what i want to do is to time the time it takes for the script to run from start to completion... or can this still be done using the Benchmark module?
      i'm sooo sorry, thanks cjf for pointing out the article :-)
Re: YA newbie question: benchmarking your scripts?
by asdfgroup (Beadle) on May 24, 2002 at 10:13 UTC
    And of course you can benchmark whole script with help of time command. Like
    [nikita@home nikita]$ time perl -e 'for (1..100000) {}' real 0m0.065s user 0m0.030s sys 0m0.010s