Sha256: 35435f30cab90e444635fbcc68782639f9fa2dba295fe0e9ccc75ad69625b596

Contents?: true

Size: 393 Bytes

Versions: 29

Compression:

Stored size: 393 Bytes

Contents

require 'benchmark/ips'

module Foo
	class Bar
	end
end


THINGS = {
	'Bar' => Foo::Bar
}

Benchmark.ips do |x|
	x.report("const_get('Bar')") do |i|
		while (i -= 1) > 0
			Foo.const_get('Bar')
		end
	end

	x.report("const_get(:Bar)") do |i|
		while (i -= 1) > 0
			Foo.const_get(:Bar)
		end
	end

	x.report("Hash\#[]") do |i|
		while (i -= 1) > 0
			THINGS['Bar']
		end
	end
	
	x.compare!
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
utopia-2.11.1 benchmarks/const_vs_hash.rb
utopia-2.11.0 benchmarks/const_vs_hash.rb
utopia-2.10.0 benchmarks/const_vs_hash.rb
utopia-2.9.5 benchmarks/const_vs_hash.rb
utopia-2.9.3 benchmarks/const_vs_hash.rb
utopia-2.9.2 benchmarks/const_vs_hash.rb
utopia-2.9.1 benchmarks/const_vs_hash.rb
utopia-2.9.0 benchmarks/const_vs_hash.rb
utopia-2.8.2 benchmarks/const_vs_hash.rb
utopia-2.8.1 benchmarks/const_vs_hash.rb
utopia-2.8.0 benchmarks/const_vs_hash.rb
utopia-2.7.0 benchmarks/const_vs_hash.rb
utopia-2.6.0 benchmarks/const_vs_hash.rb
utopia-2.5.5 benchmarks/const_vs_hash.rb
utopia-2.5.4 benchmarks/const_vs_hash.rb
utopia-2.5.3 benchmarks/const_vs_hash.rb
utopia-2.5.1 benchmarks/const_vs_hash.rb
utopia-2.5.0 benchmarks/const_vs_hash.rb
utopia-2.4.1 benchmarks/const_vs_hash.rb
utopia-2.4.0 benchmarks/const_vs_hash.rb