Sha256: 78fa0c6828efca2f6d12d48f26c1489ab111299db632e0d012370683687b3608

Contents?: true

Size: 461 Bytes

Versions: 29

Compression:

Stored size: 461 Bytes

Contents

require 'benchmark/ips'

class A
end

class B
	def self.do
	end
end

class C
	def self.do
	end
end

Benchmark.ips do |x|
	x.report("responds_to? (nothing)") do |times|
		while (times -= 1) >= 0
			A.do if A.respond_to?(:do)
		end
	end
	
	x.report("B (empty method)") do |times|
		while (times -= 1) >= 0
			B.do
		end
	end
	
	x.report("responds_to? (empty method)") do |times|
		while (times -= 1) >= 0
			C.do if C.respond_to?(:do)
		end
	end
	
	x.compare!
end

Version data entries

29 entries across 29 versions & 1 rubygems

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