Created
March 1, 2018 14:42
-
-
Save ilnurnasyrov2/59b5a77238d2715280304fa145940794 to your computer and use it in GitHub Desktop.
This file contains 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
class Aclass | |
def some_method | |
end | |
end | |
class Bclass < Aclass | |
end | |
class Cclass < Bclass | |
end | |
class Dclass < Cclass | |
end | |
module Amodule | |
def some_method | |
end | |
end | |
module Bmodule | |
end | |
module Cmodule | |
end | |
class DclassInheritedFromModules | |
include Amodule | |
include Bmodule | |
include Cmodule | |
end | |
require "benchmark" | |
dmodule = DclassInheritedFromModules.new | |
dclass = Dclass.new | |
n = 100_000_000 | |
Benchmark.bm do |x| | |
x.report "class method lookup" do | |
n.times { dclass.some_method } | |
end | |
x.report "module method lookup" do | |
n.times { dmodule.some_method } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment