Created
July 31, 2014 20:11
-
-
Save schwern/b5774115432e8da81e0e to your computer and use it in GitHub Desktop.
Moo speed up coercion + default with eval block instead of DIE handler.
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
| { | |
| package Foo; | |
| use Moo; | |
| has with_coerce1 => ( | |
| is => 'rw', | |
| coerce => sub { 1 }, | |
| default => sub { 1 }, | |
| ); | |
| has with_coerce2 => ( | |
| is => 'rw', | |
| coerce => sub { 1 }, | |
| default => sub { 1 }, | |
| ); | |
| has with_coerce3 => ( | |
| is => 'rw', | |
| coerce => sub { 1 }, | |
| default => sub { 1 }, | |
| ); | |
| } | |
| Foo->new for 1..1_000_000; | |
| __END__ | |
| $ git branch | |
| bug/rt.cpan.org-97653 | |
| * master | |
| $ time perl -Ilib ~/tmp/test.plx | |
| real 0m14.192s | |
| user 0m14.170s | |
| sys 0m0.018s | |
| $ git co bug/rt.cpan.org-97653 | |
| Switched to branch 'bug/rt.cpan.org-97653' | |
| $ git branch | |
| * bug/rt.cpan.org-97653 | |
| master | |
| $ time perl -Ilib ~/tmp/test.plx | |
| real 0m4.733s | |
| user 0m4.710s | |
| sys 0m0.015s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment