| Filename | /home/doy/coding/src/Moose/blib/lib//Moose/Meta/Attribute/Native.pm |
| Statements | Executed 44 statements in 666µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Native::__ANON__[:26] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Attribute::Native; | ||||
| 2 | |||||
| 3 | 1 | 4µs | our $VERSION = '1.19'; | ||
| 4 | 1 | 67µs | $VERSION = eval $VERSION; # spent 10µs executing statements in string eval | ||
| 5 | 1 | 3µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 6 | |||||
| 7 | 1 | 10µs | my @trait_names = qw(Bool Counter Number String Array Hash Code); | ||
| 8 | |||||
| 9 | 1 | 7µs | for my $trait_name (@trait_names) { | ||
| 10 | 7 | 37µs | my $trait_class = "Moose::Meta::Attribute::Native::Trait::$trait_name"; | ||
| 11 | 7 | 96µs | 7 | 3.00ms | my $meta = Class::MOP::Class->initialize( # spent 3.00ms making 7 calls to Class::MOP::Class::initialize, avg 428µs/call |
| 12 | "Moose::Meta::Attribute::Custom::Trait::$trait_name" | ||||
| 13 | ); | ||||
| 14 | 7 | 79µs | 7 | 2.05ms | if ($meta->find_method_by_name('register_implementation')) { # spent 2.05ms making 7 calls to Class::MOP::Class::find_method_by_name, avg 294µs/call |
| 15 | my $class = $meta->name->register_implementation; | ||||
| 16 | Moose->throw_error( | ||||
| 17 | "An implementation for $trait_name already exists " . | ||||
| 18 | "(found '$class' when trying to register '$trait_class')" | ||||
| 19 | ); | ||||
| 20 | } | ||||
| 21 | $meta->add_method(register_implementation => sub { | ||||
| 22 | # resolve_metatrait_alias will load classes anyway, but throws away | ||||
| 23 | # their error message; we WANT to die if there's a problem | ||||
| 24 | 10 | 145µs | 5 | 164ms | Class::MOP::load_class($trait_class); # spent 164ms making 5 calls to Class::MOP::load_class, avg 32.8ms/call |
| 25 | return $trait_class; | ||||
| 26 | 7 | 172µs | 7 | 2.22ms | }); # spent 2.22ms making 7 calls to Class::MOP::Mixin::HasMethods::add_method, avg 317µs/call |
| 27 | } | ||||
| 28 | |||||
| 29 | 1 | 46µs | 1; | ||
| 30 | |||||
| 31 | __END__ |