Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/Attribute/Native.pm |
Statements | Executed 38 statements in 169µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 8µs | 10µs | BEGIN@1.25 | Moose::
1 | 1 | 1 | 6µs | 17µs | BEGIN@6 | Moose::Meta::Attribute::Native::
1 | 1 | 1 | 4µs | 7µs | BEGIN@2.26 | Moose::
0 | 0 | 0 | 0s | 0s | __ANON__[:26] | Moose::Meta::Attribute::Native::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | 2 | 13µs | 2 | 11µs | # spent 10µs (8+1) within Moose::BEGIN@1.25 which was called:
# once (8µs+1µs) by Moose::BEGIN@43 at line 1 # spent 10µs making 1 call to Moose::BEGIN@1.25
# spent 1µs making 1 call to strict::import |
2 | 2 | 28µs | 2 | 10µs | # spent 7µs (4+3) within Moose::BEGIN@2.26 which was called:
# once (4µs+3µs) by Moose::BEGIN@43 at line 2 # spent 7µs making 1 call to Moose::BEGIN@2.26
# spent 3µs making 1 call to warnings::import |
3 | package Moose::Meta::Attribute::Native; | ||||
4 | 1 | 100ns | our $VERSION = '2.1605'; | ||
5 | |||||
6 | 2 | 91µs | 2 | 29µs | # spent 17µs (6+12) within Moose::Meta::Attribute::Native::BEGIN@6 which was called:
# once (6µs+12µs) by Moose::BEGIN@43 at line 6 # spent 17µs making 1 call to Moose::Meta::Attribute::Native::BEGIN@6
# spent 12µs making 1 call to Module::Runtime::import |
7 | |||||
8 | 1 | 800ns | my @trait_names = qw(Bool Counter Number String Array Hash Code); | ||
9 | |||||
10 | 1 | 400ns | for my $trait_name (@trait_names) { | ||
11 | 7 | 3µs | my $trait_class = "Moose::Meta::Attribute::Native::Trait::$trait_name"; | ||
12 | 7 | 7µs | 7 | 246µs | my $meta = Class::MOP::Class->initialize( # spent 246µs making 7 calls to Class::MOP::Class::initialize, avg 35µs/call |
13 | "Moose::Meta::Attribute::Custom::Trait::$trait_name" | ||||
14 | ); | ||||
15 | |||||
16 | 7 | 5µs | 7 | 245µs | if ($meta->find_method_by_name('register_implementation')) { # spent 245µs making 7 calls to Class::MOP::Class::find_method_by_name, avg 35µ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 | require_module($trait_class); | ||||
25 | return $trait_class; | ||||
26 | 7 | 14µs | 7 | 182µs | }); # spent 182µs making 7 calls to Class::MOP::Mixin::HasMethods::add_method, avg 26µs/call |
27 | } | ||||
28 | |||||
29 | 1 | 5µs | 1; | ||
30 | |||||
31 | # ABSTRACT: Delegate to native Perl types | ||||
32 | |||||
33 | __END__ |