The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

PURPOSE

Compares the speed of the constructor in four equivalent classes built using different tools:

Moo_MXTML

Moo with MooX::Types::MooseLike::Base types and non-Sub::Quote coderef coercions.

Moo_TT

Moo with Type::Tiny types and coercions.

Moose

Moose with Moose type constraints and coderef coercions. Class is made immutable.

Moose_TT

Moose with Type::Tiny type constraints and coercions. Class is made immutable.

RESULTS

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.)

DEPENDENCIES

To run this script, you will need:

Type::Tiny::XS, Moo, MooX::Types::MooseLike::Base, Moose.

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE

This software is copyright (c) 2013-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.