Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
The real trick isn't optimizing your code but optimizing your solution.

this is a good paraphrase of my answer... hell yeah, i optimize my code... but it's the data bottlenecks i optimize, not the millisecond differences you'd only get by porting to C. when all i get is milliseconds, i purely write for readability/security/correctness, not speed.

i try to understand what my database does to retrieve/store data, so the requests i make of it can use indices, not full searches. i try to dump the results of a query into a perl hash if i reuse it, to avoid requerying. i try to keep the data ordered in such a way as to avoid the actual data structure causing problems, etc.

i find that for what i want to do one or both of {perl, mysql} always has the data structure i want (in terms of efficiency of search, add, delete), so i can almost always avoid doing the hard work.. that makes for efficiency of development on several levels. by knowing perl/mysql i have an easy answer to all my data structure problems, i just have to use the struct, not build one first. and it is readable by others simply by virtue of being standardized (ie SQL 92)

second, if there is an error in the data structure, the easy to fix ones are my fault (i used the struct wrong), and the hard ones are someone elses. if i'm using say, some feature new to mysql 4.0.0alpha and it breaks, we just add it to the bug list and wait for 4.0.1 -- the fix is free, i or my employer don't have to pay for me to debug, rewrite, debug, etc...

if i were the guy writting mysql it would be a different story, but it's not like they write it in perl either...

In reply to Re: Re: Optimizing existing Perl code (in practise) by Xanatax
in thread Optimizing existing Perl code (in practise) by JaWi

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 browsing the Monastery: (7)
As of 2024-04-18 14:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found