Benchmarking Ruby 2.7.0's Numbered Parameters

Ruby 2.7.0 added numbered block parameters. There was some controversy which resulted in the initial syntax of @n changing to _n. I like the change.

This is what it looks like:

# regular named params
HASH.map { |a, b| [a, b] }

# new numbered params
HASH.map { [_1, _2] }

Anyway, I wondered if there was any performance impact in this change so I threw together a quick benchmark. Result: it’s just as fast as named params.

Warming up --------------------------------------
        named params   143.381k i/100ms
     numbered params   142.011k i/100ms
Calculating -------------------------------------
        named params      2.027M (± 1.6%) i/s -     10.180M in   5.022400s
     numbered params      1.996M (± 2.4%) i/s -     10.083M in   5.053749s

Comparison:
        named params:  2027451.7 i/s
     numbered params:  1996273.3 i/s - same-ish: difference falls within error