Skip to content

Instantly share code, notes, and snippets.

@sergeykolychev
Created July 30, 2018 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergeykolychev/56d8b80a253161791e4b59e7a0d5149a to your computer and use it in GitHub Desktop.
Save sergeykolychev/56d8b80a253161791e4b59e7a0d5149a to your computer and use it in GitHub Desktop.
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