I did consider that, but since the strftime variant was already losing badly, it didn't seem critical.

You're right, though, wrapping the fetch of @fixedLocaltime in a sub (returning a ref to the array) call kills the performance of the strftime variant a bit more.

$ perl testMonth.pl Benchmark: running inlineArrayLookup, preBuiltArrayLookup, strftimeLoo +kup, strftimeSubLookup, substrLookup, each for at least 2 CPU seconds +... inlineArrayLookup: 2 wallclock secs ( 2.12 usr + 0.00 sys = 2.12 CP +U) @ 513847.17/s (n=1089356) preBuiltArrayLookup: 2 wallclock secs ( 2.09 usr + 0.01 sys = 2.10 +CPU) @ 568700.00/s (n=1194270) strftimeLookup: 1 wallclock secs ( 1.81 usr + 0.35 sys = 2.16 CPU) +@ 223003.24/s (n=481687) strftimeSubLookup: 2 wallclock secs ( 1.74 usr + 0.26 sys = 2.00 CP +U) @ 182455.50/s (n=364911) substrLookup: 2 wallclock secs ( 2.19 usr + 0.01 sys = 2.20 CPU) @ +446835.91/s (n=983039) Rate strftimeSubLookup strftimeLookup substrLo +okup inlineArrayLookup preBuiltArrayLookup strftimeSubLookup 182455/s -- -18% +-59% -64% -68% strftimeLookup 223003/s 22% -- +-50% -57% -61% substrLookup 446836/s 145% 100% + -- -13% -21% inlineArrayLookup 513847/s 182% 130% + 15% -- -10% preBuiltArrayLookup 568700/s 212% 155% + 27% 11% --

--
Mike

Edit by tye, change PRE to CODE around long lines


In reply to Re: Re: Replacing $mon with Jan, Feb, Mar by regex or other means by RMGir
in thread Replacing $mon with Jan, Feb, Mar by regex or other means by jonnyfolk

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.