Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
use 5.028;
use strictures 2;
use Benchmark 'timethese';
use Class::XSAccessor ();
#............Moose............
{
package Foo::Moose;
use Moose;
has bar => (is => 'rw', isa => 'Int');
__PACKAGE__->meta->make_immutable;
}
my $moose= Foo::Moose->new;
sub moose {
$moose->bar(32);
my $x= $moose->bar;
}
#.............Moo...........
{
package Foo::Moo;
use Types::Standard 'Int';
use Moo;
has bar => (is => 'rw', isa => Int);
}
my $moo= Foo::Moo->new;
sub moo {
$moo->bar(32);
my $x= $moo->bar;
}
#............Mouse............
{
package Foo::Mouse;
use Mouse;
has bar => (is => 'rw', isa => 'Int');
__PACKAGE__->meta->make_immutable;
}
my $mouse= Foo::Mouse->new;
sub mouse {
$mouse->bar(32);
my $x= $mouse->bar;
}
print "Testing Perl $], Moo $Moo::VERSION, Moose $Moose::VERSION, Mouse $Mouse::VERSION\n";
timethese(-3, {'Moose' => \&moose, 'Moo' => \&moo, 'Mouse' => \&mouse});
__END__
Testing Perl 5.028000, Moo 2.003004, Moose 2.2011, Mouse v2.5.4
Benchmark: running Moo, Moose, Mouse for at least 3 CPU seconds...
Moo: 3 wallclock secs ( 3.25 usr + 0.00 sys = 3.25 CPU) @ 666953.54/s (n=2167599)
Moose: 3 wallclock secs ( 3.12 usr + 0.00 sys = 3.12 CPU) @ 1487541.67/s (n=4641130)
Mouse: 3 wallclock secs ( 3.12 usr + 0.00 sys = 3.12 CPU) @ 6130097.44/s (n=19125904)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment