Skip to content

Instantly share code, notes, and snippets.

@headius
Forked from anonymous/gist:1137946
Created August 10, 2011 19:59
Show Gist options
  • Save headius/1138026 to your computer and use it in GitHub Desktop.
Save headius/1138026 to your computer and use it in GitHub Desktop.
JRuby versus Java impls of fib(35), both using RubyFixnum objects
# Java impl of fib, statically typed but still using RubyFixnum objects
headius@headius-desktop:~/projects/jruby$ ~/hsx-hotspot/build/linux/jdk-linux-i586/bin/java -server -cp lib/jruby.jar:build/classes/test/ org.jruby.test.bench.BenchFixnumFibRecursive
Took 936ms for boxedFib(35) = 9227465
Took 847ms for boxedFib(35) = 9227465
Took 905ms for boxedFib(35) = 9227465
Took 943ms for boxedFib(35) = 9227465
Took 873ms for boxedFib(35) = 9227465
# Ruby impl of fib. The 20% different from Java is optimization opportunities in JRuby and invokedynamic, but we're very close to Java perf here.
headius@headius-desktop:~/projects/jruby$ JAVA_HOME=~/hsx-hotspot/build/linux/jdk-linux-i586/ bin/jruby -v --server bench/bench_fib_recursive.rb 5 35
jruby 1.7.0.dev (ruby-1.8.7-p330) (2011-08-09 fffffff) (OpenJDK Server VM 1.7.0) [linux-i386-java]
9227465
1.385000 0.000000 1.385000 ( 1.274000)
9227465
1.156000 0.000000 1.156000 ( 1.156000)
9227465
1.158000 0.000000 1.158000 ( 1.158000)
9227465
1.181000 0.000000 1.181000 ( 1.180000)
9227465
1.152000 0.000000 1.152000 ( 1.152000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment