... 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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |