There's more than one way to do things | |
PerlMonks |
Re^5: Anonymous function called in forbidden scalar contextby BrowserUk (Patriarch) |
on Sep 30, 2011 at 18:02 UTC ( [id://928884]=note: print w/replies, xml ) | Need Help?? |
Is Memoize really useful for computations? For many expensive calculations that are called many times it can be very useful. The following benchmark compares Ack1() which does no memoisation with Ack2() which is identical, but has been memoised. The results at the bottom show that Ack2() is over 5,448 times faster than Ack1():
However, all is not lost if you cannot use Memoize, as it is not very difficult to do the memoisation yourself. Ack3() does this using a simple hash and it runs nearly 4 times faster than Ack2() and 25,000 time faster than the non-memoised version. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Seekers of Perl Wisdom
|
|