Skip to content

Instantly share code, notes, and snippets.

@zaeleus
Created April 17, 2012 22:18
Show Gist options
  • Save zaeleus/2409431 to your computer and use it in GitHub Desktop.
Save zaeleus/2409431 to your computer and use it in GitHub Desktop.
n = 5_000_000
puts Benchmark.measure { n.times { Float("9.0") } }
puts Benchmark.measure { n.times { "9.0".to_f } }
# user, system, user+system, real in seconds
# master (0e5f208f)
$ RBXOPT=-X19 bin/rbx -v
rubinius 2.0.0dev (1.9.3 0e5f208f yyyy-mm-dd JI) [x86_64-apple-darwin11.3.0]
$ RBXOPT=-X19 bin/rbx ~/float_benchmark.rb
19.099325 0.022679 19.122004 ( 18.981508)
1.602614 0.000624 1.603238 ( 1.589942)
# with patch
$ RBXOPT=-X19 bin/rbx -v
rubinius 2.0.0dev (1.9.3 6d1467d1 yyyy-mm-dd JI) [x86_64-apple-darwin11.3.0]
$ RBXOPT=-X19 bin/rbx ~/float_benchmark.rb
2.471862 0.004314 2.476176 ( 2.362196)
1.768438 0.001124 1.769562 ( 1.695914)
# MRI 1.9.3
$ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]
$ ruby ~/float_benchmark.rb
1.310000 0.000000 1.310000 ( 1.315623)
1.280000 0.000000 1.280000 ( 1.277073)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment