Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False negative for Performance/StringIdentifierArgument with string interpolation #386

Closed
Earlopain opened this issue Nov 21, 2023 · 0 comments · Fixed by #387
Closed

False negative for Performance/StringIdentifierArgument with string interpolation #386

Earlopain opened this issue Nov 21, 2023 · 0 comments · Fixed by #387

Comments

@Earlopain
Copy link
Contributor

Earlopain commented Nov 21, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant