Sha256: 6f9e4be6f1d6c1da19b828fc0dc05822c3a711319577e17b4082efcb7a088f33

Contents?: true

Size: 530 Bytes

Versions: 6

Compression:

Stored size: 530 Bytes

Contents

require 'bench_press'
require 'bigdecimal'
extend BenchPress

name 'Float vs Rational power'
author 'Claudio Bustos'
date '2011-02-02'
summary "
On ruby, the maximum size of a float is #{Float::MAX}. 
With Rational, we can raise to integer numbers and surpass Float maximum.
What is the speed reduction using Rational?"

reps 1000 #number of repetitions
int=10
rat=10.quo(1)
bd=BigDecimal("10")
measure "Using float pow" do
	int**307
end

measure "Using rational" do
	rat**307
end

measure "Using big decimal pow" do
	bd**307
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
distribution-0.7.3 benchmark/power.rb
distribution-0.7.2 benchmark/power.rb
distribution-0.7.1 benchmark/power.rb
distribution-0.7.0 benchmark/power.rb
distribution-0.6.0 benchmark/power.rb
distribution-0.5.0 benchmark/power.rb