The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

PURPOSE

Benchmarking the following multi method:

   multi method fib ( Int $i where { $_ <= 1 } ) {
      return $i;
   }
   
   multi method fib ( Int $i ) {
      return $self->fib($i-1) + $self->fib($i-2);
   }

The code that invokes the multi method is:

   my $obj = $implementation->new;
   $obj->fib($_) for 0..10;

Modules tested are:

RESULTS

Running perl -Ilib examples/benchmarks-multisub.pl:

            Rate    MXMM Kavorka   Plain
 MXMM    0.809/s      --    -85%   -100%
 Kavorka  5.38/s    565%      --    -98%
 Plain     283/s  34873%   5161%      --

Kavorka is the faster multi-method implementation, though is significantly slower than avoiding multi-methods.

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE

This software is copyright (c) 2013 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.