Last active
January 2, 2016 01:49
-
-
Save SamSaffron/8232978 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
module MA; end | |
module MB; end | |
module MC; end | |
module MD; end | |
module ME; end | |
class A; end | |
class B < A | |
include MA | |
include MB | |
include MC | |
include MD | |
include ME | |
end | |
class C < B; end | |
class D < C; end | |
require 'benchmark' | |
class A | |
100_000.times do |i| | |
define_method "a#{i}" do | |
1 | |
end | |
end | |
end | |
@d = D.new | |
@a = A.new | |
methods = [] | |
100_000.times{ |i| methods << "a#{i}".to_sym } | |
GC.disable | |
Benchmark.bm do |x| | |
x.report("flat") { 100_000.times{ |i| @a.send methods[i] } } | |
x.report("deep") { 100_000.times{ |i| @d.send methods[i] } } | |
end |
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
chruby 2.0.0 && ruby dispatch.rb && chruby 2.1.0 && ruby dispatch.rb |
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
user system total real | |
flat 0.030000 0.000000 0.030000 ( 0.031963) | |
deep 0.040000 0.000000 0.040000 ( 0.036419) | |
user system total real | |
flat 0.040000 0.000000 0.040000 ( 0.035921) | |
deep 0.040000 0.000000 0.040000 ( 0.041264) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment