Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: As Efficient as Possible

by crashtest (Curate)
on Apr 02, 2010 at 21:40 UTC ( [id://832557]=note: print w/replies, xml ) Need Help??


in reply to As Efficient as Possible

Premature optimization is the root of all evil.
~ Donald Knuth

You fail to specify how to optimize. For execution time? Memory usage? Lines of code?

In my experience, Knuth's quote is not an exaggeration. I've done stupid stuff in the name of unneeded optimization more times than I can count. Are you having specific performance problems? You seem to indicate not. If it works, leave it alone.

Replies are listed 'Best First'.
Re^2: As Efficient as Possible
by BrowserUk (Patriarch) on Apr 02, 2010 at 22:14 UTC

    Knuth also said:

    The improvement in speed from Exampe 2 to Example 2a is only about 12%, and many people would pronounce that insignificant. The conventional wisdom shared by many of today's software engineers calls for ignoring efficiency in the small; but I believe this is simply an overreaction to the abuses they see being practiced by pennywise-and-pound-foolish programmers, who can't debug or maintain their "optimized" programs.

    In established engineering disciplines a 12 % improvement, easily obtained, is never considered marginal; and I believe the same viewpoint should prevail in software engineering.

    Of course I wouldn't bother making such optimizations on a one-shot job, but when it's a question of preparing quality programs, I don't want to restrict myself to tools that deny me such efficiencies.


    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.
      That is why I want to understand what the code is doing before I put it in my code base. but, I still need my code to be as fast as possible.

        mr_p:

        but, I still need my code to be as fast as possible.

        No, you really don't. You need it to be fast enough. You can spend incredible amounts of time and energy making things faster, prettier, more elegant, etc. There's no shortage of time sinks (aka rabbit holes) in our profession.

        If your requirements document tells you to "make it as fast as possible", you need to do one of:

        • Ask for a large budget so you can spend time implementing your code in assembler,
        • Learn how to enjoy unpaid overtime, or
        • Ask them to tell you how fast is fast enough.

        Remember, a requirement is testable. A requirement that "it be as fast as possible" isn't a requirement--you can't tell when you've achieved it. A requirement that says "the system must return a response within 500 ms over 90% of the time" is a fine requirement. It's testable, and you'll know when it's time to move to the next item on your to-do list.

        </learned_from_experience>

        ...roboticus

Re^2: As Efficient as Possible
by mr_p (Scribe) on Apr 02, 2010 at 22:09 UTC

    Yes, I should have used the word optimize.

    No, I am not having any problems. But the Data is time sensitive data.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2024-03-28 17:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found