++ed by:
TOBYINK

1 PAUSE user(s)
6 non-PAUSE user(s).

Toby Inkster

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.861/s      --    -89%   -100%
 Kavorka  7.81/s    807%      --    -97%
 Plain     276/s  32026%   3441%      --

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.




Hosting generously
sponsored by Bytemark