[plt-scheme] Unexpected slowdown using memoized function

From: Eric Hanchrow (offby1 at blarg.net)
Date: Sun Aug 12 10:47:33 EDT 2007

>>>>> "Grant" == Grant Rettke <grettke at acm.org> writes:

    Grant> 381 took 23 seconds 383 took 39 seconds

The only thing I can think of is that you're calling P with lots of
distinct values -- i.e., you're doing

         (P 10)
         (P 9893)
         (P 33)
         ...

and no two values are the same.  Obviously if you don't call P with
the same values more than once, you get no benefit from memoization;
and also obviously memoization has _some_ cost (namely, the memory to
store all the inputs and outputs).

-- 
[T]he only two jobs at which I have ever earned my living are
soul musician and linguist
        Geoffrey K. Pullum


Posted on the users mailing list.