Compares the speed of the constructor in four equivalent classes built using different tools:
Moo with MooX::Types::MooseLike::Base types and non-Sub::Quote coderef coercions.
Moo with Type::Tiny types and coercions.
Moose with Moose type constraints and coderef coercions. Class is made immutable.
Moose with Type::Tiny type constraints and coercions. Class is made immutable.
For both Moose and Moo, Type::Tiny type constraints are clearly faster than the conventional approach.
With Type::Tiny::XS:
Rate Moo_MXTML Moose Moo_TT Moose_TT Moo_MXTML 3040/s -- -44% -64% -83% Moose 5463/s 80% -- -35% -69% Moo_TT 8373/s 175% 53% -- -52% Moose_TT 17612/s 479% 222% 110% --
Without Type::Tiny::XS:
Rate Moo_MXTML Moo_TT Moose Moose_TT Moo_MXTML 3140/s -- -41% -50% -63% Moo_TT 5288/s 68% -- -16% -38% Moose 6305/s 101% 19% -- -26% Moose_TT 8574/s 173% 62% 36% --
(Tested versions: Type::Tiny 0.045_03, Type::Tiny::XS 0.004, Moose 2.1207, Moo 1.005000, and MooX::Types::MooseLike 0.25.)
To run this script, you will need:
Type::Tiny::XS, Moo, MooX::Types::MooseLike::Base, Moose.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2013-2014, 2017 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 Type::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Type::Tiny
CPAN shell
perl -MCPAN -e shell install Type::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.