Memoize

I was trying to use memoize the other day (v 1.2 from Dan Berger --
is there a different/better one?). Ran into some problems...

In this dumb example, where I'm passing the same parameter every time,
the speed should *blaze*, should it not?

This doesn't work for me. I see no measurable speed difference in these
three cases. What am I doing wrong?

Thanks,
Hal

require 'memoize'

include Memoize

def zeta(x)
r2d = 360.0/(2.0*Math::PI) # Radians to degrees
2.0*(Math.sin(x/r2d))*(Math.cos(x/r2d))
end

puts Time.now
1000000.times { z = zeta(2.0) }
puts Time.now

memoize(:zeta)

puts Time.now
1000000.times { z = zeta(2.0) }
puts Time.now

memoize(:zeta,"z.cache")

puts Time.now
1000000.times { z = zeta(2.0) }
puts Time.now

rubyhacker@gmail.com wrote:

I was trying to use memoize the other day (v 1.2 from Dan Berger --
is there a different/better one?). Ran into some problems...

Ignore this post -- I made it 48 hours or so ago. A gateway glitch
delayed it, I guess.

Hal