Sha256: 221b97b55132d19195fb27fc7baf484e74e7bb437968f515d801a42ae1592201

Contents?: true

Size: 424 Bytes

Versions: 13

Compression:

Stored size: 424 Bytes

Contents

# frozen_string_literal: true

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

13 entries across 13 versions & 1 rubygems

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