Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
chruby 2.0.0 && ruby dispatch.rb && chruby 2.1.0 && ruby dispatch.rb
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
Something went wrong with that request. Please try again.