in reply to Re: Reminder to self: must use Memoize more often!
in thread Reminder to self: must use Memoize more often!

On my machine at least, fib6 is 4% faster than fib5:

my @fib6_cache; sub fib6 { my $n = shift; $fib6_cache[ $n ] //= $n < 2 ? $n : ( $fib6_cache[ $n-1 ] //= fib6($n-1) ) + ( $fib6_cache[ $n-2 ] //= fib6($n-2) ); }
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^3: Reminder to self: must use Memoize more often!
by BrowserUk (Patriarch) on Jan 12, 2013 at 15:03 UTC

    Fair enough. I guess we're into Benchmark vagaries. (T'was a bit unnecessary given the 1000% already gained :)


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    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.