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

Hello Monks,

Please execuse me for asking this question.

I have cgi application it has lots of modules.

I want to get execution time for each and every module when I click every process.

Is it possible?

Thanks,
Rose

Replies are listed 'Best First'.
Re: Get Execution time
by davorg (Chancellor) on Sep 05, 2006 at 14:21 UTC

    There is (unsurprisingly) more than one way to do it!

    Simon Cozens' article Profiling Perl gives a good overview of techniques.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: Get Execution time
by madbombX (Hermit) on Sep 05, 2006 at 15:06 UTC
    There are a few ways to do it to include profiling (as already stated). brian d foy has an article is DDJ (Dr. Dobbs Jornal) www.ddj.com about profiling that I have found to be extremely useful in getting me going: http://www.ddj.com/184404580. He uses a profiling module called Devel::SmallProf. It might also be handy to use the faster version of this Devel::FastProf.
    $ perl -d:FastProf myscript.pl $ fprofpp fastprof.out > fast_profiler_report.txt

    If you are looking for something with a little less information, you can always Benchmark your code.

    # Benchmark use Benchmark; my @_t; $_t[1] = new Benchmark; # module/program/subroutine goes here $_t[2] = new Benchmark; $_t[0] = timediff($_t[2], $_t[1]); print "$0 took: ". timestr($_t[0]);

    Eric