Created
August 14, 2012 18:16
-
-
Save headius/3351417 to your computer and use it in GitHub Desktop.
attr_accessor versus ivar-returning method on MacRuby, JRuby, MRI, and Rubinius
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
system ~/projects/jruby $ macruby -rbenchmark -e "class A; def initialize; @a = 1; end; attr_accessor :a; end; 5.times { puts Benchmark.measure { a = A.new; i=0; while i<100_000_000; a.a; i+=1; end } }" | |
5.690000 0.000000 5.690000 ( 5.686256) | |
5.660000 0.000000 5.660000 ( 5.657916) | |
5.670000 0.000000 5.670000 ( 5.664147) | |
5.690000 0.010000 5.700000 ( 5.691450) | |
5.690000 0.000000 5.690000 ( 5.699265) | |
system ~/projects/jruby $ macruby -rbenchmark -e "class A; def initialize; @a = 1; end; def a; @a; end; end; 5.times { puts Benchmark.measure { a = A.new; i=0; while i<100_000_000; a.a; i+=1; end } }" | |
5.680000 0.010000 5.690000 ( 5.685863) | |
5.690000 0.000000 5.690000 ( 5.693407) | |
5.670000 0.000000 5.670000 ( 5.662142) | |
5.670000 0.000000 5.670000 ( 5.677396) | |
5.670000 0.000000 5.670000 ( 5.671487) | |
system ~/projects/jruby $ jruby -rbenchmark -e "class A; def initialize; @a = 1; end; attr_accessor :a; end; 5.times { puts Benchmark.measure { a = A.new; i=0; while i<100_000_000; a.a; i+=1; end } }" | |
4.240000 0.070000 4.310000 ( 3.982000) | |
3.950000 0.010000 3.960000 ( 3.844000) | |
4.170000 0.020000 4.190000 ( 4.056000) | |
4.110000 0.020000 4.130000 ( 4.054000) | |
4.230000 0.010000 4.240000 ( 4.161000) | |
system ~/projects/jruby $ jruby -rbenchmark -e "class A; def initialize; @a = 1; end; def a; @a; end; end; 5.times { puts Benchmark.measure { a = A.new; i=0; while i<100_000_000; a.a; i+=1; end } }" | |
4.960000 0.090000 5.050000 ( 4.602000) | |
5.050000 0.020000 5.070000 ( 4.972000) | |
4.540000 0.020000 4.560000 ( 4.439000) | |
4.480000 0.020000 4.500000 ( 4.393000) | |
4.470000 0.020000 4.490000 ( 4.404000) | |
system ~/projects/jruby $ jruby -Xcompile.invokedynamic=true -rbenchmark -e "class A; def initialize; @a = 1; end; attr_accessor :a; end; 5.times { puts Benchmark.measure { a = A.new; i=0; while i<100_000_000; a.a; i+=1; end } }" | |
1.440000 0.060000 1.500000 ( 1.226000) | |
1.120000 0.010000 1.130000 ( 1.086000) | |
1.430000 0.010000 1.440000 ( 1.348000) | |
1.350000 0.010000 1.360000 ( 1.326000) | |
1.370000 0.000000 1.370000 ( 1.338000) | |
system ~/projects/jruby $ jruby -Xcompile.invokedynamic=true -rbenchmark -e "class A; def initialize; @a = 1; end; def a; @a; end; end; 5.times { puts Benchmark.measure { a = A.new; i=0; while i<100_000_000; a.a; i+=1; end } }" | |
1.580000 0.060000 1.640000 ( 1.324000) | |
1.230000 0.010000 1.240000 ( 1.203000) | |
1.460000 0.010000 1.470000 ( 1.432000) | |
1.470000 0.010000 1.480000 ( 1.430000) | |
1.460000 0.000000 1.460000 ( 1.430000) | |
system ~/projects/jruby $ ruby-1.9.3 -rbenchmark -e "class A; def initialize; @a = 1; end; attr_accessor :a; end; 5.times { puts Benchmark.measure { a = A.new; i=0; while i<100_000_000; a.a; i+=1; end } }" | |
8.490000 0.000000 8.490000 ( 8.493755) | |
8.490000 0.010000 8.500000 ( 8.488008) | |
8.510000 0.000000 8.510000 ( 8.510421) | |
8.510000 0.000000 8.510000 ( 8.513919) | |
8.940000 0.010000 8.950000 ( 8.958641) | |
system ~/projects/jruby $ ruby-1.9.3 -rbenchmark -e "class A; def initialize; @a = 1; end; def a; @a; end; end; 5.times { puts Benchmark.measure { a = A.new; i=0; while i<100_000_000; a.a; i+=1; end } }" | |
10.650000 0.000000 10.650000 ( 10.650636) | |
10.720000 0.000000 10.720000 ( 10.727523) | |
10.640000 0.010000 10.650000 ( 10.643023) | |
10.630000 0.000000 10.630000 ( 10.632696) | |
10.660000 0.000000 10.660000 ( 10.655910) | |
system ~/projects/jruby $ ../rubinius/bin/rbx -rbenchmark -e "class A; def initialize; @a = 1; end; attr_accessor :a; end; 5.times { puts Benchmark.measure { a = A.new; i=0; while i<100_000_000; a.a; i+=1; end } }" | |
6.815830 0.004340 6.820170 ( 6.820387) | |
6.847853 0.003030 6.850883 ( 6.837327) | |
1.171625 0.000144 1.171769 ( 1.171874) | |
1.164679 0.000409 1.165088 ( 1.165070) | |
1.165900 0.001009 1.166909 ( 1.166942) | |
system ~/projects/jruby $ ../rubinius/bin/rbx -rbenchmark -e "class A; def initialize; @a = 1; end; def a; @a; end; end; 5.times { puts Benchmark.measure { a = A.new; i=0; while i<100_000_000; a.a; i+=1; end } }" | |
6.491848 0.002118 6.493966 ( 6.471991) | |
1.186767 0.000118 1.186885 ( 1.186871) | |
1.179810 0.000155 1.179965 ( 1.180013) | |
1.182180 0.000815 1.182995 ( 1.183034) | |
1.235873 0.000114 1.235987 ( 1.236103) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment