Sha256: 286adff3de922d61219c774f79cc676e079a355939c63179010ff7ab0b8be5c4

Contents?: true

Size: 492 Bytes

Versions: 13

Compression:

Stored size: 492 Bytes

Contents

# frozen_string_literal: true

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

13 entries across 13 versions & 1 rubygems

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