Yes, you're quite right - if I were going to use those conditionals more than a few times in any given script I'd set up the hashes once only and spread the overhead. This was more about satisfying my curiosity than about optimisation - in the spirit of that curiosity, here are the results with any hashes involved set once only:
10000 trials of abigail (494.672ms total), 49us/trial 10000 trials of broquaint (93.071s total), 9.307ms/trial 10000 trials of esper (533.643ms total), 53us/trial 10000 trials of ferrency (547.466ms total), 54us/trial 10000 trials of george_sherston1 (654.023ms total), 65us/trial 10000 trials of george_sherston2 (837.320ms total), 83us/trial 10000 trials of george_sherston3 (715.834ms total), 71us/trial 10000 trials of samtregar (1.022s total), 102us/trial


§ George Sherston

In reply to Re: Re: Re: Conditional idiom : "if X equals Y or Z" ?? - benchmark by George_Sherston
in thread Conditional idiom : "if X equals Y or Z" ?? by George_Sherston

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.