Re: Optimize my script
- From: paul@xxxxxxxx (Paul Johnson)
- Date: Wed, 18 Jul 2007 15:29:51 +0200
On Wed, Jul 18, 2007 at 10:17:00AM +0000, JeeBee wrote:
Thanks Paul, I should profile of course, should have thought about that.
I tried the below, but it's not quite clear what this means to me.
When I run with "./analyze.pl foo bar" the execution time is fast, so the
problem is not starting up/exiting of Perl, and I conclude it must be
inside the script somwhere.
DirHandle::BEGIN takes only 0.01 seconds, so that's not it either.
I don't see the regular expressions anywhere, unfortunately.
Is there a way to change that?
Thanks
$ perl -d:DProf ./analyze.pl traplas-example output
...
$ dprofpp
Total Elapsed Time = 1.109888 Seconds
User+System Time = 1.039888 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c Name
0.96 0.010 0.010 2 0.0050 0.0050 DirHandle::BEGIN
0.00 - -0.000 1 - - DirHandle::DESTROY
0.00 - -0.000 1 - - strict::bits
0.00 - -0.000 1 - - strict::import
0.00 - -0.000 1 - - Symbol::BEGIN
0.00 - -0.000 1 - - Symbol::gensym
0.00 - -0.000 1 - - DirHandle::read
0.00 - -0.000 1 - - DirHandle::open
0.00 - -0.000 2 - - Exporter::import
0.00 - -0.000 1 - - DirHandle::new
0.00 - 0.010 2 - 0.0050 main::BEGIN
I'm not very familiar with the profiler, but at a guess, I would say
that the profiler only counts time in subroutines, and that the majority
(all?) of your program is not in a subroutine, and over 99% of the
execution time of your program is in that code.
I see the following options:
- split your code into subroutines to gain a better understanding of
what is taking how much time
- install Devel::Cover and run
$ perl -MDevel::Cover ./analyze.pl traplas-example output
$ cover
to gain a finer grained but less accurate profiling report
- go back to guessing - you were probably right ;-)
- post your code so that other people can guess too
- buy more hardware
--
Paul Johnson - paul@xxxxxxxx
http://www.pjcj.net
.
- Follow-Ups:
- Re: Optimize my script
- From: Chas Owens
- Re: Optimize my script
- From: Paul Johnson
- Re: Optimize my script
- References:
- Optimize my script
- From: JeeBee
- Re: Optimize my script
- From: JeeBee
- Re: Optimize my script
- From: Paul Johnson
- Re: Optimize my script
- From: JeeBee
- Optimize my script
- Prev by Date: Re: Executing commands through Perl
- Next by Date: Re: Optimize my script
- Previous by thread: Re: Optimize my script
- Next by thread: Re: Optimize my script
- Index(es):
Relevant Pages
|