Created
December 17, 2012 14:47
-
-
Save anonymous/4318806 to your computer and use it in GitHub Desktop.
RE: http://eval.in/4817 ... Singleton methods add some cost of execution to objects in MRI 1.9.3.
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
~/.rvm/rubies/jruby-1.6.5/bin/ruby | |
before singleton method definition | |
0.991000 0.000000 0.991000 ( 0.990000) | |
after singleton method definition | |
0.641000 0.000000 0.641000 ( 0.641000) | |
~/.rvm/rubies/jruby-1.6.7.2/bin/ruby | |
before singleton method definition | |
0.554000 0.000000 0.554000 ( 0.555000) | |
after singleton method definition | |
0.502000 0.000000 0.502000 ( 0.502000) | |
~/.rvm/rubies/jruby-1.6.8/bin/ruby | |
before singleton method definition | |
0.530000 0.000000 0.530000 ( 0.530000) | |
after singleton method definition | |
0.510000 0.000000 0.510000 ( 0.510000) | |
~/.rvm/rubies/jruby-1.7.0/bin/ruby | |
before singleton method definition | |
1.730000 0.040000 1.770000 ( 0.859000) | |
after singleton method definition | |
0.700000 0.000000 0.700000 ( 0.518000) | |
~/.rvm/rubies/jruby-1.7.1/bin/ruby | |
before singleton method definition | |
1.610000 0.040000 1.650000 ( 0.779000) | |
after singleton method definition | |
0.760000 0.000000 0.760000 ( 0.578000) | |
~/.rvm/rubies/jruby-head/bin/ruby | |
before singleton method definition | |
1.540000 0.050000 1.590000 ( 0.775000) | |
after singleton method definition | |
0.710000 0.010000 0.720000 ( 0.526000) | |
~/.rvm/rubies/ree-1.8.7-2012.02/bin/ruby | |
before singleton method definition | |
0.830000 0.000000 0.830000 ( 0.828132) | |
after singleton method definition | |
0.800000 0.000000 0.800000 ( 0.806208) | |
~/.rvm/rubies/ruby-1.8.7-p352/bin/ruby | |
before singleton method definition | |
0.930000 0.000000 0.930000 ( 0.930660) | |
after singleton method definition | |
0.940000 0.000000 0.940000 ( 0.942419) | |
~/.rvm/rubies/ruby-1.8.7-p358/bin/ruby | |
before singleton method definition | |
0.960000 0.000000 0.960000 ( 0.962650) | |
after singleton method definition | |
0.950000 0.000000 0.950000 ( 0.954485) | |
~/.rvm/rubies/ruby-1.8.7-p370/bin/ruby | |
before singleton method definition | |
0.960000 0.000000 0.960000 ( 0.963616) | |
after singleton method definition | |
0.950000 0.000000 0.950000 ( 0.947487) | |
~/.rvm/rubies/ruby-1.9.3-p194/bin/ruby | |
before singleton method definition | |
0.160000 0.000000 0.160000 ( 0.166036) | |
after singleton method definition | |
0.410000 0.000000 0.410000 ( 0.414524) | |
~/.rvm/rubies/ruby-1.9.3-p286/bin/ruby | |
before singleton method definition | |
0.390000 0.000000 0.390000 ( 0.392831) | |
after singleton method definition | |
1.050000 0.000000 1.050000 ( 1.050109) | |
~/.rvm/rubies/ruby-1.9.3-p327/bin/ruby | |
before singleton method definition | |
0.180000 0.000000 0.180000 ( 0.185082) | |
after singleton method definition | |
0.410000 0.000000 0.410000 ( 0.401608) |
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
require "benchmark" | |
include Benchmark | |
puts "\n\n#{`which ruby`.chomp}" | |
GC.disable unless RUBY_PLATFORM =~ /java/ | |
TIMES = 1_000 | |
eval "def run; 10_000.times { #{"$a[5]\n" * TIMES} } end" | |
$a = [1,2,3,4,5,6,7,8,9,10] | |
puts "before singleton method definition" | |
puts measure { run } | |
def $a.x; end | |
puts "after singleton method definition" | |
puts measure { run } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment