Created
December 5, 2011 01:47
-
-
Save sikachu/1431961 to your computer and use it in GitHub Desktop.
Revisions
-
sikachu created this gist
Dec 5, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ require 'benchmark' class A0 def foo true end end (1..1000).each do |n| eval <<-RUBY class A#{n} < A#{n-1} end RUBY end class B0 def foo true end end (1..1000).each do |n| eval <<-RUBY class B#{n} < B#{n-1} def foo super end end RUBY end Benchmark.bmbm do |x| x.report("implicit") { A1000.new.foo } x.report("explicit") { B1000.new.foo } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ [~] ruby benchmark.rb Rehearsal -------------------------------------------- implicit 0.010000 0.000000 0.010000 ( 0.000501) explicit 0.000000 0.000000 0.000000 ( 0.008302) ----------------------------------- total: 0.010000sec user system total real implicit 0.000000 0.000000 0.000000 ( 0.000139) explicit 0.010000 0.000000 0.010000 ( 0.007057) [~]