False negative for Performance/StringIdentifierArgument
with string interpolation #386
Closed
Description
As per rubocop/rubocop#12383 (comment) in the same vein as rubocop/rubocop#12373
Benchmark script:
require 'benchmark/ips'
puts `ruby -v`
def foo_bar
end
bar = "bar"
Benchmark.ips do |x|
x.report('symbol arg') { send(:"foo_#{bar}") }
x.report('string arg') { send("foo_#{bar}") }
x.compare!
end
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux-musl]
Warming up --------------------------------------
symbol arg 641.253k i/100ms
string arg 602.373k i/100ms
Calculating -------------------------------------
symbol arg 6.385M (± 0.6%) i/s - 32.063M in 5.022123s
string arg 6.023M (± 0.5%) i/s - 30.119M in 5.000717s
Comparison:
symbol arg: 6384545.4 i/s
string arg: 6023007.5 i/s - 1.06x slower
Metadata
Assignees
Labels
No labels