1. Ok, this one I discussed in an earlier reply.
  2. Faster accessors.... Do you know which portions of code are causing problems? Faster accessors only make sense if you've got a slow one causing you trouble. And even then, "trimming cycles" is often much less effective than "a more efficient algorithm"
  3. Yes, I would suggest avoiding calling any code that doesn't do anything. Especially if it does nothing in O(n^2) time. ;) How to detect that it's not doing anything? I guess you've got to look at what it's designed to do, ask why that's useful, and if you determine that it's not doing anything useful, stop calling it. A good regression test suite is helpful when doing that sort of refactoring.
  4. Exiting loops early is an optimization on a linear operation. Lazy initialization or lazy evaluation is a technique where you do some expensive work just in time, with the hope that maybe you never have to do it at all. If you know you've got to do it, sometimes an opposite technique of pulling as much of the work into startup time as possible can also be beneficial. Which is best for your application has to be your decision based on a lot of factors.
  5. If you're going to go about rearranging code that does work but just looks silly, especially when it's not really impacting performance, be sure that you've got good regression tests in place first, or just leave it alone.

Dave


In reply to Re: how to improve the performance of a perl program by davido
in thread how to improve the performance of a perl program by ghosh123

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.