Skip to content

Instantly share code, notes, and snippets.

@headius
Created November 29, 2011 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save headius/1402736 to your computer and use it in GitHub Desktop.
Save headius/1402736 to your computer and use it in GitHub Desktop.
Explorations of Ruby 1.9.3, CastOff, and JRuby performance on fib and tarai
# Real fixnums obviously helps a lot in 1.9.3 and CastOff.
ruby-1.9.3-p0 ~/projects/jruby $ ruby -v bench/bench_fib_float_recursive.rb 5 30ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]
832040.0
0.330000 0.000000 0.330000 ( 0.336662)
832040.0
0.330000 0.000000 0.330000 ( 0.330731)
832040.0
0.340000 0.000000 0.340000 ( 0.331758)
832040.0
0.330000 0.000000 0.330000 ( 0.332715)
832040.0
0.330000 0.000000 0.330000 ( 0.332331)
ruby-1.9.3-p0 ~/projects/jruby $ cast_off --run bench/bench_fib_float_recursive.rb 5 30832040.0
0.220000 0.000000 0.220000 ( 0.218369)
832040.0
0.220000 0.000000 0.220000 ( 0.221209)
832040.0
0.220000 0.000000 0.220000 ( 0.220458)
832040.0
0.220000 0.000000 0.220000 ( 0.217716)
832040.0
0.250000 0.000000 0.250000 ( 0.250451)
ruby-1.9.3-p0 ~/projects/jruby $ ruby -v bench/bench_fib_recursive.rb 5 30
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]
0.180000 0.000000 0.180000 ( 0.183686)
0.180000 0.000000 0.180000 ( 0.183474)
0.190000 0.000000 0.190000 ( 0.183440)
0.180000 0.000000 0.180000 ( 0.183403)
0.180000 0.000000 0.180000 ( 0.183839)
ruby-1.9.3-p0 ~/projects/jruby $ cast_off --run bench/bench_fib_recursive.rb 5 30
0.060000 0.010000 0.070000 ( 0.053983)
0.050000 0.000000 0.050000 ( 0.054199)
0.050000 0.000000 0.050000 ( 0.054230)
0.050000 0.000000 0.050000 ( 0.054481)
0.060000 0.000000 0.060000 ( 0.054941)
# JRuby still wins on both, but I'm not entirely sure why...
ruby-1.9.3-p0 ~/projects/jruby $ jruby bench/bench_fib_float_recursive.rb 10 30
832040.0
0.185000 0.000000 0.185000 ( 0.154000)
832040.0
0.065000 0.000000 0.065000 ( 0.065000)
832040.0
0.056000 0.000000 0.056000 ( 0.056000)
832040.0
0.078000 0.000000 0.078000 ( 0.078000)
832040.0
0.041000 0.000000 0.041000 ( 0.041000)
832040.0
0.041000 0.000000 0.041000 ( 0.041000)
832040.0
0.042000 0.000000 0.042000 ( 0.042000)
832040.0
0.042000 0.000000 0.042000 ( 0.042000)
832040.0
0.042000 0.000000 0.042000 ( 0.042000)
832040.0
0.044000 0.000000 0.044000 ( 0.044000)
ruby-1.9.3-p0 ~/projects/jruby $ jruby bench/bench_fib_recursive.rb 10 30
0.126000 0.000000 0.126000 ( 0.095000)
0.032000 0.000000 0.032000 ( 0.032000)
0.033000 0.000000 0.033000 ( 0.033000)
0.033000 0.000000 0.033000 ( 0.033000)
0.032000 0.000000 0.032000 ( 0.032000)
0.032000 0.000000 0.032000 ( 0.032000)
0.033000 0.000000 0.033000 ( 0.033000)
0.032000 0.000000 0.032000 ( 0.032000)
0.032000 0.000000 0.032000 ( 0.032000)
0.032000 0.000000 0.032000 ( 0.032000)
# CastOff does very well on tarai
ruby-1.9.3-p0 ~/projects/jruby $ ruby -v bm_app_tarai.rb
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]
0.845492
0.845843
0.845498
0.843641
0.843561
ruby-1.9.3-p0 ~/projects/jruby $ cast_off --run bm_app_tarai.rb
0.053275
0.052842
0.053815
0.053394
0.053144
ruby-1.9.3-p0 ~/projects/jruby $ jruby bm_app_tarai.rb 20
0.23
0.118
0.119
0.118
0.118
# If we remove some guards from JRuby (Fixnum modification, result is Fixnum, overflow, self call method guards), it gets closer to CastOff
ruby-1.9.3-p0 ~/projects/jruby $ jruby bm_app_tarai.rb
0.145
0.081
0.086
0.084
0.081
# Remaining overhead may indicate inefficiencies in how JRuby's compiling this, obscuring some optimization potential from JVM.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment