H
Hal Fulton
(Reposting via ML as gateway apparently didn't send this through.)
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:I) # 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
memoizezeta)
puts Time.now
1000000.times { z = zeta(2.0) }
puts Time.now
memoizezeta,"z.cache")
puts Time.now
1000000.times { z = zeta(2.0) }
puts Time.now
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:I) # 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
memoizezeta)
puts Time.now
1000000.times { z = zeta(2.0) }
puts Time.now
memoizezeta,"z.cache")
puts Time.now
1000000.times { z = zeta(2.0) }
puts Time.now