Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I hear lots of "speed" talk here and it is almost always premature nano-optimization. You describe problems with premature optimization. I think the nano-optimization and micro-optimization is perhaps a worse problem for many Perl programmers.

I marvel at people (including me, sometimes) running benchmarks to estimate how much faster single quotes are to double quotes, whether for is faster before a loop or after a statement, whether && is faster than and, whether arrays are faster than hashes, whether globals are faster than references, etc.

The most common conclusion is that X is 20% faster than Y (seriously). And that usually means your script can be changed from taking 1.2 seconds to run to an impressive 1.1999 seconds to run!

If a script is running "too slow", then optimizing simple things is very unlikely to make it run "fast enough". On rare occasions, you'll find a fairly simple thing that is getting done many thousands of times such that making it significantly faster will make your while program only moderately faster.

But don't assume you have such a rare case unless you have some decent evidence. That is what things like Devel::Dprof are meant to help you figure out. So work on figuring out what the bottleneck is before you spend effort trying to remove it.

But, if a script is running "too slow", then your only reasonable hope for fixing that is to make changes to the global structure, to the algorithm. Instead of making one operation 20% faster, make it so you process/store the data in a different format/order so that you can find what you want with one operation instead with 10,000, for example.

        - tye (but my friends call me "Tye")

In reply to (tye)Re: Premature optimization by tye
in thread Premature optimization by Ovid

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (7)
    As of 2014-09-16 09:49 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite cookbook is:










      Results (158 votes), past polls