Sha256: ebcfe024d0bb05bd1043877aeb312ea26bbdee66dfb0aa91909875faacba60e9

Contents?: true

Size: 554 Bytes

Versions: 7

Compression:

Stored size: 554 Bytes

Contents

$:.unshift(File.expand_path(File.dirname(__FILE__)+"/../lib"))
require 'bench_press'
require 'distribution'
extend BenchPress

name 'calculate factorial vs looking on a Hash'
author 'Claudio Bustos'
date '2011-01-31'
summary "
Is better create a lookup table for factorial or just calculate it?
Distribution::MathExtension::SwingFactorial has a lookup table 
for factorials n<20
"

reps 1000 #number of repetitions

measure "Lookup" do
	Math.factorial(19)
end

measure "calculate" do
	Distribution::MathExtension::SwingFactorial.naive_factorial(19)
end

Version data entries

7 entries across 7 versions & 1 rubygems

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