Benchmarking the following method call defined with several different modules:
method foo ( Int $x, ArrayRef[Int] $y ) { return [ $x, $y ]; }
Modules tested are:
Kavorka (of course)
Type::Params (not as sugary, but probably the fastest pure Perl method signature implementation on CPAN)
Function::Parameters plus Moose type constraints
Function::Parameters plus Type::Tiny type constraints
Method::Signatures
MooseX::Method::Signatures
In all cases, Type::Tiny::XS is installed. This gives a speed boost to Kavorka, Type::Params, and one of the Function::Parameters examples.
Running perl -Ilib examples/benchmarks.pl:
perl -Ilib examples/benchmarks.pl
Rate MXMS MS FP_Moose TParams FP_TT Kavorka MXMS 654/s -- -91% -93% -98% -98% -98% MS 7129/s 990% -- -18% -78% -82% -83% FP_Moose 8719/s 1233% 22% -- -74% -78% -79% TParams 32905/s 4933% 362% 277% -- -17% -20% FP_TT 39648/s 5964% 456% 355% 20% -- -3% Kavorka 41008/s 6172% 475% 370% 25% 3% --
Kavorka is the winner.
Yes, that's right, it's about 60 or so times faster than MooseX::Method::Signatures.
Note that if Any::Moose is loaded before Moose, then Method::Signatures will be able to use Mouse's type constraints instead of Moose's. In that case, the Method::Signatures results are much closer to Kavorka. (In the table above they'd be about 30000/s.)
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2014 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.
To install Kavorka, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Kavorka
CPAN shell
perl -MCPAN -e shell install Kavorka
For more information on module installation, please visit the detailed CPAN module installation guide.