Skip to content

Instantly share code, notes, and snippets.

@nobu
Created January 7, 2026 10:15
Show Gist options
  • Select an option

  • Save nobu/f373134644f5c7214a6b15decaea69ef to your computer and use it in GitHub Desktop.

Select an option

Save nobu/f373134644f5c7214a6b15decaea69ef to your computer and use it in GitHub Desktop.
Access to reserved name argument
user system total real
case_hash 0.068478 0.003698 0.072176 ( 0.072223)
case_binding 0.220886 0.014623 0.235509 ( 0.235632)
user system total real
case_hash 0.065353 0.004143 0.069496 ( 0.069540)
case_binding 0.184500 0.018979 0.203479 ( 0.203601)
require 'benchmark'
N = 1000_000
def case_hash(case:)
{case:}[:case]
end
def case_binding(case:)
binding.local_variable_get(:case)
end
Benchmark.bm(12) do |bm|
bm.report("case_hash") {N.times {case_hash(case: :ok)}}
bm.report("case_binding") {N.times {case_binding(case: :ok)}}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment