-
-
Save haileys/8233106 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 | |
eval "def send_a\n #{100_000.times.map { |i| "$a.a#{i}\n" }.join} end" | |
eval "def send_d\n #{100_000.times.map { |i| "$d.a#{i}\n" }.join} end" | |
GC.disable | |
Benchmark.bm do |x| | |
x.report("flat ") { send_a } | |
x.report("deep ") { send_d } | |
x.report("flat2") { send_a } | |
x.report("deep2") { send_d } | |
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
~/crap/ssaffronbench 2.0.0-p247 λ ruby x.rb | |
user system total real | |
flat 0.030000 0.000000 0.030000 ( 0.024657) | |
deep 0.030000 0.000000 0.030000 ( 0.029719) | |
flat2 0.010000 0.000000 0.010000 ( 0.015495) | |
deep2 0.020000 0.000000 0.020000 ( 0.015226) | |
~/crap/ssaffronbench 2.0.0-p247 λ ruby x.rb | |
user system total real | |
flat 0.030000 0.000000 0.030000 ( 0.024831) | |
deep 0.030000 0.000000 0.030000 ( 0.029739) | |
flat2 0.010000 0.000000 0.010000 ( 0.015438) | |
deep2 0.020000 0.000000 0.020000 ( 0.015434) | |
~/crap/ssaffronbench 2.0.0-p247 λ ruby x.rb | |
user system total real | |
flat 0.020000 0.000000 0.020000 ( 0.023261) | |
deep 0.030000 0.000000 0.030000 ( 0.028004) | |
flat2 0.020000 0.000000 0.020000 ( 0.014744) | |
deep2 0.010000 0.000000 0.010000 ( 0.014675) |
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
~/crap/ssaffronbench ruby-2.1.0 λ ruby x.rb | |
user system total real | |
flat 0.030000 0.000000 0.030000 ( 0.027147) | |
deep 0.040000 0.000000 0.040000 ( 0.036408) | |
flat2 0.010000 0.000000 0.010000 ( 0.015233) | |
deep2 0.020000 0.000000 0.020000 ( 0.014806) | |
~/crap/ssaffronbench ruby-2.1.0 λ ruby x.rb | |
user system total real | |
flat 0.030000 0.000000 0.030000 ( 0.030373) | |
deep 0.040000 0.000000 0.040000 ( 0.035366) | |
flat2 0.020000 0.000000 0.020000 ( 0.015790) | |
deep2 0.010000 0.000000 0.010000 ( 0.015687) | |
~/crap/ssaffronbench ruby-2.1.0 λ ruby x.rb | |
user system total real | |
flat 0.030000 0.000000 0.030000 ( 0.029211) | |
deep 0.040000 0.000000 0.040000 ( 0.037345) | |
flat2 0.010000 0.000000 0.010000 ( 0.015964) | |
deep2 0.020000 0.000000 0.020000 ( 0.015936) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment