------ art_19194_14061130.1138760311107
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
I added a "sleep 1" line to zeta to exaggerate the time of an uncached
method call.
It is working.
--Brian Buckley
def zeta(x)
sleep 1
r2d = 360.0/(2.0*Math::PI) # Radians to degrees
2.0*(Math.sin(x/r2d))*(Math.cos(x/r2d))
end
t1 = Time.now
10.times { z = zeta(2.0) }
t2 = Time.now
memoize(:zeta)
t3 = Time.now
10.times { z = zeta(2.0) }
t4 = Time.now
memoize(:zeta,"z.cache")
t5 = Time.now
10.times { z = zeta(2.0) }
t6 = Time.now
puts "#{t2 - t1}, #{t4 - t3}, #{t6 - t5}" # => 10.0, 1.0, 0.0
------ art_19194_14061130.1138760311107--