Sha256: b0f55093bf003fdeabd88283400b9c2c77ac3dac74786bf3dca1c8e27edcb3e9

Contents?: true

Size: 310 Bytes

Versions: 13

Compression:

Stored size: 310 Bytes

Contents

# frozen_string_literal: true

require 'benchmark/ips'

STRING_HASH = { "foo" => "bar" }
SYMBOL_HASH = { :foo => "bar"  }

Benchmark.ips do |x|
	x.report("string") { STRING_HASH["foo"] }
	x.report("symbol") { SYMBOL_HASH[:foo]  }
	x.report("symbol-from-string") { SYMBOL_HASH["foo".to_sym]  }
	
	x.compare!
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
utopia-2.15.1 benchmark/string_vs_symbol.rb
utopia-2.15.0 benchmark/string_vs_symbol.rb
utopia-2.14.0 benchmark/string_vs_symbol.rb
utopia-2.13.4 benchmark/string_vs_symbol.rb
utopia-2.13.3 benchmark/string_vs_symbol.rb
utopia-2.13.2 benchmark/string_vs_symbol.rb
utopia-2.13.1 benchmark/string_vs_symbol.rb
utopia-2.13.0 benchmark/string_vs_symbol.rb
utopia-2.12.4 benchmarks/string_vs_symbol.rb
utopia-2.12.3 benchmarks/string_vs_symbol.rb
utopia-2.12.2 benchmarks/string_vs_symbol.rb
utopia-2.12.1 benchmarks/string_vs_symbol.rb
utopia-2.12.0 benchmarks/string_vs_symbol.rb