Created
August 30, 2010 16:53
-
-
Save metaskills/557674 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bench_press' | |
extend BenchPress | |
author 'Ken Collins' | |
summary 'Object class inspection vs duck typing.' | |
reps 100_000 | |
module Foo | |
class Bar | |
def to_foo | |
end | |
end | |
class Batz | |
end | |
end | |
@bar = Foo::Bar.new | |
@batz = Foo::Batz.new | |
measure "Object#is_a?" do | |
@bar.is_a?(Foo::Bar) | |
@batz.is_a?(Foo::Bar) | |
end | |
measure "Object#respond_to?" do | |
@bar.respond_to?(:to_foo) | |
@batz.respond_to?(:to_foo) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment