Skip to content

Instantly share code, notes, and snippets.

@mrkn
Created November 12, 2016 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrkn/e4e07a416d393fe3a3fb9d1c215130fc to your computer and use it in GitHub Desktop.
Save mrkn/e4e07a416d393fe3a3fb9d1c215130fc to your computer and use it in GitHub Desktop.
require 'benchmark/ips'
Benchmark.ips do |x|
rat = 123456789123456789/987654321r
flt = 123456789.123456789
fix = 1234567890
big = 12345678901234567890
x.report('rat + fix') { rat + fix }
x.report('rat + big') { rat + big }
x.report('rat + flt') { rat + flt }
x.report('rat + rat') { rat + rat }
x.report('rat - fix') { rat - fix }
x.report('rat - big') { rat - big }
x.report('rat - flt') { rat - flt }
x.report('rat - rat') { rat - rat }
x.report('rat * big') { rat * big }
x.report('rat * flt') { rat * flt }
x.report('rat * rat') { rat * rat }
x.report('rat / flt') { rat / flt }
end
@tadd
Copy link

tadd commented Nov 13, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment