| Filename | /usr/local/lib/perl/5.18.2/Moose/Meta/Attribute/Native.pm |
| Statements | Executed 42 statements in 251µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 9µs | 18µs | Moose::BEGIN@1 |
| 1 | 1 | 1 | 7µs | 22µs | Moose::Meta::Attribute::Native::BEGIN@6 |
| 1 | 1 | 1 | 6µs | 9µs | Moose::BEGIN@2 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Native::__ANON__[:26] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 2 | 19µs | 2 | 28µs | # spent 18µs (9+9) within Moose::BEGIN@1 which was called:
# once (9µs+9µs) by Moose::BEGIN@43 at line 1 # spent 18µs making 1 call to Moose::BEGIN@1
# spent 9µs making 1 call to strict::import |
| 2 | 2 | 45µs | 2 | 13µs | # spent 9µs (6+3) within Moose::BEGIN@2 which was called:
# once (6µs+3µs) by Moose::BEGIN@43 at line 2 # spent 9µs making 1 call to Moose::BEGIN@2
# spent 3µs making 1 call to warnings::import |
| 3 | package Moose::Meta::Attribute::Native; | ||||
| 4 | 1 | 400ns | our $VERSION = '2.1604'; | ||
| 5 | |||||
| 6 | 2 | 127µs | 2 | 37µs | # spent 22µs (7+15) within Moose::Meta::Attribute::Native::BEGIN@6 which was called:
# once (7µs+15µs) by Moose::BEGIN@43 at line 6 # spent 22µs making 1 call to Moose::Meta::Attribute::Native::BEGIN@6
# spent 15µs making 1 call to Module::Runtime::import |
| 7 | |||||
| 8 | 1 | 1µs | my @trait_names = qw(Bool Counter Number String Array Hash Code); | ||
| 9 | |||||
| 10 | 1 | 600ns | for my $trait_name (@trait_names) { | ||
| 11 | 7 | 3µs | my $trait_class = "Moose::Meta::Attribute::Native::Trait::$trait_name"; | ||
| 12 | 7 | 8µs | 7 | 359µs | my $meta = Class::MOP::Class->initialize( # spent 359µs making 7 calls to Class::MOP::Class::initialize, avg 51µs/call |
| 13 | "Moose::Meta::Attribute::Custom::Trait::$trait_name" | ||||
| 14 | ); | ||||
| 15 | |||||
| 16 | 7 | 6µs | 7 | 384µs | if ($meta->find_method_by_name('register_implementation')) { # spent 384µs making 7 calls to Class::MOP::Class::find_method_by_name, avg 55µs/call |
| 17 | my $class = $meta->name->register_implementation; | ||||
| 18 | die "An implementation for $trait_name already exists " . | ||||
| 19 | "(found '$class' when trying to register '$trait_class')" | ||||
| 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 | 2 | 3µs | 2 | 0s | require_module($trait_class); # spent 22.9ms making 2 calls to Module::Runtime::require_module, avg 11.5ms/call, recursion: max depth 1, sum of overlapping time 22.9ms |
| 25 | 2 | 8µs | return $trait_class; | ||
| 26 | 7 | 21µs | 7 | 278µs | }); # spent 278µs making 7 calls to Class::MOP::Mixin::HasMethods::add_method, avg 40µs/call |
| 27 | } | ||||
| 28 | |||||
| 29 | 1 | 7µs | 1; | ||
| 30 | |||||
| 31 | # ABSTRACT: Delegate to native Perl types | ||||
| 32 | |||||
| 33 | __END__ |