How very odd!

My testing on Win2k, ActivePerl 5.8.8 shows that the case of the data doesn't affect the timing, and that old_way is consistently just shy of 50% faster than with_tr.

Upper case data =============== Rate with_tr old_way with_tr 183850/s -- -32% old_way 272269/s 48% -- Lower case data =============== Rate with_tr old_way with_tr 182262/s -- -33% old_way 270854/s 49% --

Benchmark code:

Of course, inlining the code saves a lot of time:

Rate with_tr old_way with_tr_i old_way_i with_tr 180473/s -- -32% -39% -52% old_way 265506/s 47% -- -10% -29% with_tr_i 296058/s 64% 12% -- -20% old_way_i 372377/s 106% 40% 26% --

Benchmark code:


In reply to Re: Premature and micro optimization... by ikegami
in thread Premature and micro optimization... by chargrill

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.