... measurable penalty ...

Benchmark is tricky. When I looked at the output from your test, I thought "Heck, an 8% difference may be measurable, but it's sure not meaningful, not from Benchmark!"

I ran your code several times and got a range of advantages for  'no_lock' of 10% - 79%. Discarding outliers and doing an eyeball average gave me an advantage of about 35%. (I won't reveal the actual values I got because I don't think they're really significant; a much larger sampling of benchmark comparisons would be needed to achieve some sort of statistical significance.)

I then ran your code a few times with the  for (1 .. 1e5) { ... } loop limit set to 1e6. This runs several tens of seconds on my laptop. This produced a  'no_lock' advantage range of 4% - 25%, and an eyeball average sans outliers of about 15%.

Multiple runs of Benchmark produce a set of measurements I think is meaningful, and a massaged advantage of roughly 15% to 35% is what I would consider significant. I wouldn't dispute this point. The (rather long-winded) point I want to make is that Benchmark comparisons should always be made repeatedly in order to be meaningful, and should always be taken with a grain of salt.


Give a man a fish:  <%-{-{-{-<


In reply to Re^4: strict "vars" mode for hash key literals? by AnomalousMonk
in thread strict "vars" mode for hash key literals? by perlancar

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.