Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I am surprised nobody has mentioned this yet, but just a few days ago I was given the same decision. A big hunka hunka burning regex or a series of nested conditionals. The result is at Optimization for readability and speed (code).

The bottom line: The regex was 10 times faster than the if statements. Running it once, it wouldnt have made a difference. Running it 200 times, it did make a difference. And merlyn was right. Looking back on it, it really seems silly to have done that from a perl programmer point of view.

Something else you may be interested in (and one of the ways I did simplify and readbilityize the code) is here, at Using arrays of qr!! to simplify larger RE's for readability (code).. You might find that using a sequence of qr!!'s in your code may not only increase its readbility but also its speed.

Looking back at it, I think I wound up updating everyone in the CB with regards to speed. I did benchmark everything and it turned out to be 10x faster. The reason that particular node didnt report any speed increase is I was doing something rather stupid elsewhere in the program. :)

brother dep.

psssst, you probably could have used Super Search to find this answer! :)

--
Laziness, Impatience, Hubris, and Generosity.


In reply to Re: Efficiency of multiple if statements (code) by deprecated
in thread Efficiency of multiple if statements by scottstef

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, 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
  • 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.
  • 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 romping around the Monastery: (3)
    As of 2021-04-17 11:30 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?