| Filename | /home/doy/coding/src/Moose/blib/lib//Moose/Meta/Attribute/Native/Trait.pm |
| Statements | Executed 222 statements in 7.95ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 10 | 2 | 1 | 1.18ms | 676ms | Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for |
| 2 | 1 | 1 | 516µs | 674ms | Moose::Meta::Attribute::Native::Trait::_check_handles_values |
| 2 | 1 | 1 | 210µs | 1.03ms | Moose::Meta::Attribute::Native::Trait::_build_native_type |
| 2 | 1 | 1 | 183µs | 1.49ms | Moose::Meta::Attribute::Native::Trait::_check_helper_type |
| 5 | 1 | 1 | 124µs | 174µs | Moose::Meta::Attribute::Native::Trait::_root_types |
| 1 | 1 | 1 | 72µs | 13.6ms | Moose::Meta::Attribute::Native::Trait::BEGIN@3 |
| 1 | 1 | 1 | 51µs | 84µs | Moose::Meta::Attribute::Native::Trait::BEGIN@7 |
| 1 | 1 | 1 | 49µs | 717µs | Moose::Meta::Attribute::Native::Trait::BEGIN@198 |
| 1 | 1 | 1 | 42µs | 9.85ms | Moose::Meta::Attribute::Native::Trait::BEGIN@6 |
| 1 | 1 | 1 | 42µs | 235µs | Moose::Meta::Attribute::Native::Trait::BEGIN@5 |
| 1 | 1 | 1 | 40µs | 665µs | Moose::Meta::Attribute::Native::Trait::BEGIN@199 |
| 2 | 1 | 1 | 39µs | 39µs | Moose::Meta::Attribute::Native::Trait::CORE:match (opcode) |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Native::Trait::__ANON__[:101] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Native::Trait::__ANON__[:136] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Native::Trait::__ANON__[:158] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Native::Trait::__ANON__[:26] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Native::Trait::__ANON__[:37] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Native::Trait::__ANON__[:51] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Native::Trait::__ANON__[:80] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Attribute::Native::Trait::__ANON__[:83] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Moose::Meta::Attribute::Native::Trait; | ||||
| 3 | 3 | 165µs | 2 | 27.1ms | # spent 13.6ms (72µs+13.5) within Moose::Meta::Attribute::Native::Trait::BEGIN@3 which was called:
# once (72µs+13.5ms) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 3 # spent 13.6ms making 1 call to Moose::Meta::Attribute::Native::Trait::BEGIN@3
# spent 13.5ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456] |
| 4 | |||||
| 5 | 3 | 106µs | 2 | 429µs | # spent 235µs (42+193) within Moose::Meta::Attribute::Native::Trait::BEGIN@5 which was called:
# once (42µs+193µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 5 # spent 235µs making 1 call to Moose::Meta::Attribute::Native::Trait::BEGIN@5
# spent 193µs making 1 call to Exporter::import |
| 6 | 3 | 150µs | 2 | 19.7ms | # spent 9.85ms (42µs+9.81) within Moose::Meta::Attribute::Native::Trait::BEGIN@6 which was called:
# once (42µs+9.81ms) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 6 # spent 9.85ms making 1 call to Moose::Meta::Attribute::Native::Trait::BEGIN@6
# spent 9.81ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456] |
| 7 | 3 | 3.31ms | 2 | 117µs | # spent 84µs (51+33) within Moose::Meta::Attribute::Native::Trait::BEGIN@7 which was called:
# once (51µs+33µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 7 # spent 84µs making 1 call to Moose::Meta::Attribute::Native::Trait::BEGIN@7
# spent 33µs making 1 call to Package::DeprecationManager::__ANON__[Package/DeprecationManager.pm:61] |
| 8 | |||||
| 9 | 1 | 4µs | our $VERSION = '1.19'; | ||
| 10 | 1 | 78µs | $VERSION = eval $VERSION; # spent 11µs executing statements in string eval | ||
| 11 | 1 | 3µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 12 | |||||
| 13 | 1 | 13µs | 1 | 522µs | requires '_helper_type'; # spent 522µs making 1 call to Moose::Role::requires |
| 14 | |||||
| 15 | 1 | 13µs | 1 | 698µs | has _used_default_is => ( # spent 698µs making 1 call to Moose::Role::has |
| 16 | is => 'rw', | ||||
| 17 | isa => 'Bool', | ||||
| 18 | default => 0, | ||||
| 19 | ); | ||||
| 20 | |||||
| 21 | before '_process_options' => sub { | ||||
| 22 | 8 | 108µs | my ( $self, $name, $options ) = @_; | ||
| 23 | |||||
| 24 | 2 | 1.49ms | $self->_check_helper_type( $options, $name ); # spent 1.49ms making 2 calls to Moose::Meta::Attribute::Native::Trait::_check_helper_type, avg 746µs/call | ||
| 25 | |||||
| 26 | 6 | 150µs | 3 | 85µs | if ( !( any { exists $options->{$_} } qw( is reader writer accessor ) ) # spent 48µs making 2 calls to List::MoreUtils::any, avg 24µs/call
# spent 37µs making 1 call to UNIVERSAL::can |
| 27 | && $self->can('_default_is') ) { | ||||
| 28 | |||||
| 29 | $options->{is} = $self->_default_is; | ||||
| 30 | |||||
| 31 | $options->{_used_default_is} = 1; | ||||
| 32 | } | ||||
| 33 | |||||
| 34 | 2 | 22µs | if ( # spent 22µs making 2 calls to List::MoreUtils::any, avg 11µs/call | ||
| 35 | !( | ||||
| 36 | $options->{required} | ||||
| 37 | 2 | 56µs | || any { exists $options->{$_} } qw( default builder lazy_build ) | ||
| 38 | ) | ||||
| 39 | && $self->can('_default_default') | ||||
| 40 | ) { | ||||
| 41 | |||||
| 42 | $options->{default} = $self->_default_default; | ||||
| 43 | |||||
| 44 | Moose::Deprecated::deprecated( | ||||
| 45 | feature => 'default default for Native Trait', | ||||
| 46 | message => | ||||
| 47 | 'Allowing a native trait to automatically supply a default is deprecated.' | ||||
| 48 | . ' You can avoid this warning by supplying a default, builder, or making the attribute required' | ||||
| 49 | ); | ||||
| 50 | } | ||||
| 51 | 1 | 25µs | 1 | 355µs | }; # spent 355µs making 1 call to Moose::Role::before |
| 52 | |||||
| 53 | after 'install_accessors' => sub { | ||||
| 54 | 4 | 56µs | my $self = shift; | ||
| 55 | |||||
| 56 | 2 | 31µs | return unless $self->_used_default_is; # spent 16µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::2::_used_default_is
# spent 15µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::5::_used_default_is | ||
| 57 | |||||
| 58 | my @methods | ||||
| 59 | = $self->_default_is eq 'rw' | ||||
| 60 | ? qw( reader writer accessor ) | ||||
| 61 | : 'reader'; | ||||
| 62 | |||||
| 63 | my $name = $self->name; | ||||
| 64 | my $class = $self->associated_class->name; | ||||
| 65 | |||||
| 66 | for my $meth ( uniq grep {defined} map { $self->$_ } @methods ) { | ||||
| 67 | |||||
| 68 | my $message | ||||
| 69 | = "The $meth method in the $class class was automatically created" | ||||
| 70 | . " by the native delegation trait for the $name attribute." | ||||
| 71 | . q{ This "default is" feature is deprecated.} | ||||
| 72 | . q{ Explicitly set "is" or define accessor names to avoid this}; | ||||
| 73 | |||||
| 74 | $self->associated_class->add_before_method_modifier( | ||||
| 75 | $meth => sub { | ||||
| 76 | Moose::Deprecated::deprecated( | ||||
| 77 | feature => 'default is for Native Trait', | ||||
| 78 | message =>$message, | ||||
| 79 | ); | ||||
| 80 | } | ||||
| 81 | ); | ||||
| 82 | } | ||||
| 83 | 1 | 24µs | 1 | 313µs | }; # spent 313µs making 1 call to Moose::Role::after |
| 84 | |||||
| 85 | # spent 1.49ms (183µs+1.31) within Moose::Meta::Attribute::Native::Trait::_check_helper_type which was called 2 times, avg 746µs/call:
# 2 times (183µs+1.31ms) by Class::MOP::Class:::before at line 24, avg 746µs/call | ||||
| 86 | 10 | 139µs | my ( $self, $options, $name ) = @_; | ||
| 87 | |||||
| 88 | 2 | 18µs | my $type = $self->_helper_type; # spent 9µs making 1 call to Moose::Meta::Attribute::Native::Trait::Hash::_helper_type
# spent 9µs making 1 call to Moose::Meta::Attribute::Native::Trait::Array::_helper_type | ||
| 89 | |||||
| 90 | $options->{isa} = $type | ||||
| 91 | unless exists $options->{isa}; | ||||
| 92 | |||||
| 93 | 2 | 561µs | my $isa = Moose::Util::TypeConstraints::find_or_create_type_constraint( # spent 561µs making 2 calls to Moose::Util::TypeConstraints::find_or_create_type_constraint, avg 281µs/call | ||
| 94 | $options->{isa} ); | ||||
| 95 | |||||
| 96 | 2 | 730µs | ( $isa->is_a_type_of($type) ) # spent 730µs making 2 calls to Moose::Meta::TypeConstraint::is_a_type_of, avg 365µs/call | ||
| 97 | || confess | ||||
| 98 | "The type constraint for $name must be a subtype of $type but it's a $isa"; | ||||
| 99 | } | ||||
| 100 | |||||
| 101 | 3 | 62µs | 3 | 674ms | before 'install_accessors' => sub { (shift)->_check_handles_values }; # spent 674ms making 2 calls to Moose::Meta::Attribute::Native::Trait::_check_handles_values, avg 337ms/call
# spent 264µs making 1 call to Moose::Role::before |
| 102 | |||||
| 103 | # spent 674ms (516µs+673) within Moose::Meta::Attribute::Native::Trait::_check_handles_values which was called 2 times, avg 337ms/call:
# 2 times (516µs+673ms) by Class::MOP::Class:::before at line 101, avg 337ms/call | ||||
| 104 | 6 | 90µs | my $self = shift; | ||
| 105 | |||||
| 106 | 2 | 336µs | my %handles = $self->_canonicalize_handles; # spent 172µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::5::_canonicalize_handles
# spent 163µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::2::_canonicalize_handles | ||
| 107 | |||||
| 108 | for my $original_method ( values %handles ) { | ||||
| 109 | 15 | 467µs | my $name = $original_method->[0]; | ||
| 110 | |||||
| 111 | 5 | 673ms | my $accessor_class = $self->_native_accessor_class_for($name); # spent 673ms making 5 calls to Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for, avg 135ms/call | ||
| 112 | |||||
| 113 | 5 | 61µs | ( $accessor_class && $accessor_class->can('new') ) # spent 61µs making 5 calls to UNIVERSAL::can, avg 12µs/call | ||
| 114 | || confess | ||||
| 115 | "$name is an unsupported method type - $accessor_class"; | ||||
| 116 | } | ||||
| 117 | } | ||||
| 118 | |||||
| 119 | around '_canonicalize_handles' => sub { | ||||
| 120 | 24 | 248µs | shift; | ||
| 121 | my $self = shift; | ||||
| 122 | 4 | 57µs | my $handles = $self->handles; # spent 57µs making 4 calls to Moose::Meta::Mixin::AttributeCore::handles, avg 14µs/call | ||
| 123 | |||||
| 124 | return unless $handles; | ||||
| 125 | |||||
| 126 | unless ( 'HASH' eq ref $handles ) { | ||||
| 127 | $self->throw_error( | ||||
| 128 | "The 'handles' option must be a HASH reference, not $handles"); | ||||
| 129 | } | ||||
| 130 | |||||
| 131 | return map { | ||||
| 132 | 30 | 117µs | my $to = $handles->{$_}; | ||
| 133 | $to = [$to] unless ref $to; | ||||
| 134 | $_ => $to | ||||
| 135 | } keys %$handles; | ||||
| 136 | 1 | 21µs | 1 | 325µs | }; # spent 325µs making 1 call to Moose::Role::around |
| 137 | |||||
| 138 | around '_make_delegation_method' => sub { | ||||
| 139 | 30 | 722µs | my $next = shift; | ||
| 140 | my ( $self, $handle_name, $method_to_call ) = @_; | ||||
| 141 | |||||
| 142 | my ( $name, @curried_args ) = @$method_to_call; | ||||
| 143 | |||||
| 144 | 5 | 2.48ms | my $accessor_class = $self->_native_accessor_class_for($name); # spent 2.48ms making 5 calls to Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for, avg 495µs/call | ||
| 145 | |||||
| 146 | 5 | 82µs | die "Cannot find an accessor class for $name" # spent 82µs making 5 calls to UNIVERSAL::can, avg 16µs/call | ||
| 147 | unless $accessor_class && $accessor_class->can('new'); | ||||
| 148 | |||||
| 149 | 20 | 26.2ms | return $accessor_class->new( # spent 6.42ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::6::new
# spent 6.27ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::8::new
# spent 4.50ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::3::new
# spent 4.42ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::4::new
# spent 4.33ms making 1 call to Class::MOP::Class::__ANON__::SERIAL::7::new
# spent 174µs making 5 calls to Moose::Meta::Attribute::Native::Trait::_root_types, avg 35µs/call
# spent 43µs making 5 calls to Class::MOP::Attribute::associated_class, avg 9µs/call
# spent 24µs making 5 calls to Class::MOP::Package::name, avg 5µs/call | ||
| 150 | name => $handle_name, | ||||
| 151 | package_name => $self->associated_class->name, | ||||
| 152 | delegate_to_method => $name, | ||||
| 153 | attribute => $self, | ||||
| 154 | is_inline => 1, | ||||
| 155 | curried_arguments => \@curried_args, | ||||
| 156 | root_types => [ $self->_root_types ], | ||||
| 157 | ); | ||||
| 158 | 1 | 28µs | 1 | 274µs | }; # spent 274µs making 1 call to Moose::Role::around |
| 159 | |||||
| 160 | # spent 174µs (124+50) within Moose::Meta::Attribute::Native::Trait::_root_types which was called 5 times, avg 35µs/call:
# 5 times (124µs+50µs) by Class::MOP::Class:::around at line 149, avg 35µs/call | ||||
| 161 | 5 | 113µs | 5 | 50µs | return $_[0]->_helper_type; # spent 31µs making 3 calls to Moose::Meta::Attribute::Native::Trait::Array::_helper_type, avg 10µs/call
# spent 19µs making 2 calls to Moose::Meta::Attribute::Native::Trait::Hash::_helper_type, avg 9µs/call |
| 162 | } | ||||
| 163 | |||||
| 164 | # spent 676ms (1.18+674) within Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for which was called 10 times, avg 67.6ms/call:
# 5 times (644µs+672ms) by Moose::Meta::Attribute::Native::Trait::_check_handles_values at line 111, avg 135ms/call
# 5 times (536µs+1.94ms) by Class::MOP::Class:::around at line 144, avg 495µs/call | ||||
| 165 | 40 | 1.05ms | my ( $self, $suffix ) = @_; | ||
| 166 | |||||
| 167 | 10 | 1.46ms | my $role # spent 749µs making 4 calls to Class::MOP::Class::__ANON__::SERIAL::2::_native_type, avg 187µs/call
# spent 710µs making 6 calls to Class::MOP::Class::__ANON__::SERIAL::5::_native_type, avg 118µs/call | ||
| 168 | = 'Moose::Meta::Method::Accessor::Native::' | ||||
| 169 | . $self->_native_type . '::' | ||||
| 170 | . $suffix; | ||||
| 171 | |||||
| 172 | 10 | 415ms | Class::MOP::load_class($role); # spent 415ms making 10 calls to Class::MOP::load_class, avg 41.5ms/call | ||
| 173 | 40 | 258ms | return Moose::Meta::Class->create_anon_class( # spent 257ms making 10 calls to Moose::Meta::Class::create_anon_class, avg 25.7ms/call
# spent 111µs making 10 calls to Moose::Meta::Attribute::accessor_metaclass, avg 11µs/call
# spent 89µs making 10 calls to Moose::Meta::Attribute::delegation_metaclass, avg 9µs/call
# spent 65µs making 10 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 174 | superclasses => | ||||
| 175 | [ $self->accessor_metaclass, $self->delegation_metaclass ], | ||||
| 176 | roles => [$role], | ||||
| 177 | cache => 1, | ||||
| 178 | )->name; | ||||
| 179 | } | ||||
| 180 | |||||
| 181 | # spent 1.03ms (210µs+823µs) within Moose::Meta::Attribute::Native::Trait::_build_native_type which was called 2 times, avg 517µs/call:
# 2 times (210µs+823µs) by Class::MOP::Class::__ANON__::SERIAL::2::_native_type or Class::MOP::Class::__ANON__::SERIAL::5::_native_type at line 7 of accessor _native_type (defined at Moose/Meta/Attribute/Native/Trait.pm line 191), avg 517µs/call | ||||
| 182 | 4 | 63µs | my $self = shift; | ||
| 183 | |||||
| 184 | 4 | 84µs | 8 | 783µs | for my $role_name ( map { $_->name } $self->meta->calculate_all_roles ) { # spent 589µs making 2 calls to Moose::Meta::Class::calculate_all_roles, avg 294µs/call
# spent 89µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::2::meta
# spent 87µs making 1 call to Class::MOP::Class::__ANON__::SERIAL::5::meta
# spent 19µs making 4 calls to Class::MOP::Package::name, avg 5µs/call |
| 185 | 2 | 115µs | 2 | 39µs | return $1 if $role_name =~ /::Native::Trait::(\w+)$/; # spent 39µs making 2 calls to Moose::Meta::Attribute::Native::Trait::CORE:match, avg 20µs/call |
| 186 | } | ||||
| 187 | |||||
| 188 | die "Cannot calculate native type for " . ref $self; | ||||
| 189 | } | ||||
| 190 | |||||
| 191 | 1 | 13µs | 1 | 673µs | has '_native_type' => ( # spent 673µs making 1 call to Moose::Role::has |
| 192 | is => 'ro', | ||||
| 193 | isa => 'Str', | ||||
| 194 | lazy => 1, | ||||
| 195 | builder => '_build_native_type', | ||||
| 196 | ); | ||||
| 197 | |||||
| 198 | 3 | 131µs | 2 | 1.39ms | # spent 717µs (49+668) within Moose::Meta::Attribute::Native::Trait::BEGIN@198 which was called:
# once (49µs+668µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 198 # spent 717µs making 1 call to Moose::Meta::Attribute::Native::Trait::BEGIN@198
# spent 668µs making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:557] |
| 199 | 3 | 128µs | 2 | 1.29ms | # spent 665µs (40+625) within Moose::Meta::Attribute::Native::Trait::BEGIN@199 which was called:
# once (40µs+625µs) by Class::MOP::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP.pm:118] at line 199 # spent 665µs making 1 call to Moose::Meta::Attribute::Native::Trait::BEGIN@199
# spent 625µs making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:557] |
| 200 | |||||
| 201 | 1 | 100µs | 1; | ||
| 202 | |||||
| 203 | __END__ | ||||
# spent 39µs within Moose::Meta::Attribute::Native::Trait::CORE:match which was called 2 times, avg 20µs/call:
# 2 times (39µs+0s) by Moose::Meta::Attribute::Native::Trait::_build_native_type at line 185, avg 20µs/call |