Created
August 20, 2012 13:21
-
-
Save adaedra/3403964 to your computer and use it in GitHub Desktop.
Ruby vs JRuby
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
(pegasus) % cat benchmark.rb | |
#!/usr/bin/env ruby | |
t_b = Time.now.to_f | |
# 50'000 * sin [ -90 .. 90 ] | |
50000.times do | |
( -90 .. 90 ).each do |x| | |
Math.sin(x) | |
end | |
end | |
t_e = Time.now.to_f | |
puts "Time : #{t_e - t_b}" | |
(pegasus) % ruby -v | |
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0] | |
(pegasus) % time ruby benchmark.rb | |
Time : 4.937260150909424 | |
ruby benchmark.rb 4,94s user 0,01s system 99% cpu 4,959 total | |
(pegasus) % rvm use jruby | |
Using /Users/adaedra/.rvm/gems/jruby-1.6.7.2 | |
(pegasus) % ruby -v | |
jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_33) [darwin-x86_64-java] | |
(pegasus) % time ruby benchmark.rb | |
Time : 1.27999997138977 | |
ruby benchmark.rb 2,58s user 0,12s system 136% cpu 1,983 total | |
(pegasus) % |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment