Created
November 12, 2016 19:35
-
-
Save mrkn/e4e07a416d393fe3a3fb9d1c215130fc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I ran this on my machine: https://gist.github.com/tadd/b7a76a8b55a7f3837c2173288a735998