Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: tips on how to speed up a very slow perl script requested

by DStaal (Chaplain)
on May 06, 2009 at 14:54 UTC ( [id://762294]=note: print w/replies, xml ) Need Help??


in reply to tips on how to speed up a very slow perl script requested

I'm sure there will be a fair number of people giving specific code advice. I'll give programming advice:

Once you know you have speed problems, profile. Don't assume you know what is fast and what is slow, and don't assume you know what is being run the most often.

There is an adequate profiler that comes with Perl, that being Devel::DProf. Read up, and see what the basics are. It will help in many cases, but isn't all that extensive.

A better profiler is available in Devel::NYTProf, which will tell you exactly how many times each line of code (or block, or subroutine) is called, and how long it took. Feed your program to that with a representative sample of your data, and work out ways to avoid the slowest operations.

  • Comment on Re: tips on how to speed up a very slow perl script requested

Replies are listed 'Best First'.
Re^2: tips on how to speed up a very slow perl script requested
by BrowserUk (Patriarch) on May 06, 2009 at 15:33 UTC

    Good general advice, but but profiling the OPs code won't tell you anything that isn't readily apparent from a cursory inspection.

    Matching N elements from one file against M elements from a second, by iterating through an array containing the M elements--and respliting each element each time through--it is obvious enough where the problems lie.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: tips on how to speed up a very slow perl script requested
by Angharad (Pilgrim) on May 06, 2009 at 16:47 UTC
    Thats really good advice. Thanks. Definitely something to remember

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://762294]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-25 04:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found