Skip to content

Instantly share code, notes, and snippets.

@maxcal
Created May 19, 2015 19:14
Show Gist options
  • Select an option

  • Save maxcal/92319b0027acb16bfa67 to your computer and use it in GitHub Desktop.

Select an option

Save maxcal/92319b0027acb16bfa67 to your computer and use it in GitHub Desktop.
require 'benchmark'
@language = 'english'
string = 'Hello world'
Benchmark.bmbm do |x|
x.report { 100000.times { a = Hash[@language, string] } }
x.report { 100000.times { a = { @language => string } } }
x.report { 100000.times { a = { "{@language}" => string } } }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment