Last active
December 16, 2015 04:49
-
-
Save tobyink/5379823 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use v5.14; | |
| use Benchmark qw(cmpthese); | |
| { | |
| package Antlers; | |
| use Moose; | |
| has a => (is => "rw"); | |
| __PACKAGE__->meta->make_immutable; | |
| our $o = __PACKAGE__->new(a => 1); | |
| } | |
| { | |
| package Horns; | |
| use Moo; | |
| has a => (is => "rw"); | |
| __PACKAGE__->meta->make_immutable; | |
| our $o = __PACKAGE__->new(a => 1); | |
| } | |
| { | |
| package BigEars; | |
| use Mouse; | |
| has a => (is => "rw"); | |
| __PACKAGE__->meta->make_immutable; | |
| our $o = __PACKAGE__->new(a => 1); | |
| } | |
| say "Benchmark reading..."; | |
| cmpthese(-2, { | |
| Moose => q[ $Antlers::o->a for 1 .. 10_000 ], | |
| Moo => q[ $Horns::o->a for 1 .. 10_000 ], | |
| Mouse => q[ $BigEars::o->a for 1 .. 10_000 ], | |
| }); | |
| say "--------"; | |
| say "Benchmark writing..."; | |
| cmpthese(-2, { | |
| Moose => q[ $Antlers::o->a($_) for 1 .. 10_000 ], | |
| Moo => q[ $Horns::o->a($_) for 1 .. 10_000 ], | |
| Mouse => q[ $BigEars::o->a($_) for 1 .. 10_000 ], | |
| }); | |
| __END__ | |
| Benchmark reading... | |
| Rate Moose Mouse Moo | |
| Moose 43.3/s -- -60% -65% | |
| Mouse 108/s 149% -- -13% | |
| Moo 125/s 188% 15% -- | |
| -------- | |
| Benchmark writing... | |
| Rate Moose Mouse Moo | |
| Moose 32.5/s -- -64% -64% | |
| Mouse 89.2/s 174% -- -1% | |
| Moo 89.7/s 176% 1% -- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment