Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I require suggestions for writing a perl script which reduces or uses less CPU & Memory utilization during execution of a program.

If you want suggestions for reducing the CPU or Memory of your program, you're going to have to provide a lot more details (and code) for your program. Right now, all we can do is make vague and general guesses and suggestions around the process.

As for those suggestions we can provide . . . there's a lot of ways this can potentially be improved. First of all, you need to review your validation script, and see if there are ways it can be made faster. There are lots of ways to profile your script, the most popular current tool being Devel::NYTProf. There are articles and posts out there that offer suggestions, too (such as http://stackoverflow.com/questions/4371714/how-do-i-profile-my-perl-programs).

Another thing that could help would be to move your file finding/handling into your Perl script. Running it from the shell script means that you're starting the Perl interpreter 1000 separate times. Depending on what and how many modules you're loading, that can start to add up.

I know Parallel::ForkManager has already been suggested, and you'd be wise to investigate it. It will allow you to easily process multiple files simultaneously in a more control manner. Finding the right number of concurrent processes for maximum performance may require some testing, though.

That's about all I can think of off the top of my head without more information on what validate.pl is doing, how big the files it's validating are, what format the files are, etc.

Christopher Cashell

In reply to Re: require sugesstions for writing a perl script by topher
in thread require sugesstions for writing a perl script by lazydev

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-19 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found