How much is your time worth? Should you spend 15% more time programming something to get a 5% speed increase at run time? How many times will this code run? Will an extra one second saved per run over 3652 runs (roughly once a day for ten years) be worth it to spend two hours of programmer time (7200 seconds)? Will your code run that often? Will it only take two extra hours to write and maintain? Is your time cheaper than that of the computer, or even of the users running the code and waiting that extra one second per run?

In Donald Knuth's paper "Structured Programming With GoTo Statements", he wrote: "Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%."

Is this one of those 3% times? Likewise, Stephen C. Johnson and Brian W. Kernighan said "the strategy is definitely: first make it work, then make it right, and, finally, make it fast."

Is your code handling the common case? Is it now handling edge cases and debugged? Are you at a point that you have a well-designed, well-implemented, easily maintained program with a runtime that is just too slow? That's the time to start looking at small optimizations, and not before.


In reply to Re: When to Use Object Oriented approach in Perl? (RFC) by mr_mischief
in thread When to Use Object Oriented approach in Perl? (RFC) by thanos1983

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.