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');
__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');
}
my $moo= Foo::Moo->new;
sub moo {
$moo->bar(32);
my $x= $moo->bar;
}
#............Mouse............
{
package Foo::Mouse;
use Mouse;
has bar => (is => 'rw');
__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: 4 wallclock secs ( 3.04 usr + 0.00 sys = 3.04 CPU) @ 7639575.66/s (n=23224310)
Moose: 2 wallclock secs ( 3.15 usr + 0.00 sys = 3.15 CPU) @ 3213175.87/s (n=10121504)
Mouse: 7 wallclock secs ( 3.10 usr + 0.00 sys = 3.10 CPU) @ 6580956.45/s (n=20400965)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment