| Filename | /home/doy/coding/src/Moose/blib/lib//Moose/Meta/Role/Attribute.pm |
| Statements | Executed 152 statements in 5.06ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 15 | 2 | 2 | 811µs | 811µs | Moose::Meta::Role::Attribute::new |
| 15 | 1 | 1 | 684µs | 954µs | Moose::Meta::Role::Attribute::attach_to_role |
| 8 | 2 | 2 | 526µs | 1.11ms | Moose::Meta::Role::Attribute::clone |
| 7 | 1 | 1 | 424µs | 13.4ms | Moose::Meta::Role::Attribute::attribute_for_class |
| 1 | 1 | 1 | 70µs | 88µs | Moose::Meta::Role::Attribute::BEGIN@3 |
| 1 | 1 | 1 | 44µs | 212µs | Moose::Meta::Role::Attribute::BEGIN@6 |
| 1 | 1 | 1 | 40µs | 198µs | Moose::Meta::Role::Attribute::BEGIN@8 |
| 1 | 1 | 1 | 39µs | 165µs | Moose::Meta::Role::Attribute::BEGIN@7 |
| 1 | 1 | 1 | 39µs | 303µs | Moose::Meta::Role::Attribute::BEGIN@13 |
| 1 | 1 | 1 | 38µs | 105µs | Moose::Meta::Role::Attribute::BEGIN@4 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Attribute::__ANON__[:90] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Attribute::is_same_as |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Role::Attribute; | ||||
| 2 | |||||
| 3 | 3 | 106µs | 2 | 106µs | # spent 88µs (70+18) within Moose::Meta::Role::Attribute::BEGIN@3 which was called:
# once (70µs+18µs) by Moose::Meta::Role::BEGIN@17 at line 3 # spent 88µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@3
# spent 18µs making 1 call to strict::import |
| 4 | 3 | 110µs | 2 | 173µs | # spent 105µs (38+68) within Moose::Meta::Role::Attribute::BEGIN@4 which was called:
# once (38µs+68µs) by Moose::Meta::Role::BEGIN@17 at line 4 # spent 105µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@4
# spent 68µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 3 | 114µs | 2 | 380µs | # spent 212µs (44+168) within Moose::Meta::Role::Attribute::BEGIN@6 which was called:
# once (44µs+168µs) by Moose::Meta::Role::BEGIN@17 at line 6 # spent 212µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@6
# spent 168µs making 1 call to Exporter::import |
| 7 | 3 | 102µs | 2 | 290µs | # spent 165µs (39+125) within Moose::Meta::Role::Attribute::BEGIN@7 which was called:
# once (39µs+125µs) by Moose::Meta::Role::BEGIN@17 at line 7 # spent 165µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@7
# spent 125µs making 1 call to Exporter::import |
| 8 | 3 | 208µs | 2 | 356µs | # spent 198µs (40+158) within Moose::Meta::Role::Attribute::BEGIN@8 which was called:
# once (40µs+158µs) by Moose::Meta::Role::BEGIN@17 at line 8 # spent 198µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@8
# spent 158µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 1 | 4µs | our $VERSION = '1.19'; | ||
| 11 | 1 | 3µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 12 | |||||
| 13 | 3 | 1.36ms | 2 | 567µs | # spent 303µs (39+264) within Moose::Meta::Role::Attribute::BEGIN@13 which was called:
# once (39µs+264µs) by Moose::Meta::Role::BEGIN@17 at line 13 # spent 303µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@13
# spent 264µs making 1 call to base::import |
| 14 | |||||
| 15 | 1 | 54µs | 2 | 3.97ms | __PACKAGE__->meta->add_attribute( # spent 2.00ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 1.97ms making 1 call to Class::MOP::Mixin::meta |
| 16 | 'metaclass' => ( | ||||
| 17 | reader => 'metaclass', | ||||
| 18 | ) | ||||
| 19 | ); | ||||
| 20 | |||||
| 21 | 1 | 24µs | 2 | 1.98ms | __PACKAGE__->meta->add_attribute( # spent 1.89ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 90µs making 1 call to Class::MOP::Mixin::meta |
| 22 | 'associated_role' => ( | ||||
| 23 | reader => 'associated_role', | ||||
| 24 | ) | ||||
| 25 | ); | ||||
| 26 | |||||
| 27 | 1 | 24µs | 2 | 2.05ms | __PACKAGE__->meta->add_attribute( # spent 1.96ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 88µs making 1 call to Class::MOP::Mixin::meta |
| 28 | 'is' => ( | ||||
| 29 | reader => 'is', | ||||
| 30 | ) | ||||
| 31 | ); | ||||
| 32 | |||||
| 33 | 1 | 25µs | 2 | 2.02ms | __PACKAGE__->meta->add_attribute( # spent 1.91ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 107µs making 1 call to Class::MOP::Mixin::meta |
| 34 | 'original_options' => ( | ||||
| 35 | reader => 'original_options', | ||||
| 36 | ) | ||||
| 37 | ); | ||||
| 38 | |||||
| 39 | # spent 811µs within Moose::Meta::Role::Attribute::new which was called 15 times, avg 54µs/call:
# 8 times (442µs+0s) by Moose::Meta::Role::Attribute::clone at line 73, avg 55µs/call
# 7 times (369µs+0s) by Class::MOP::Mixin::HasAttributes::add_attribute at line 18 of Class/MOP/Mixin/HasAttributes.pm, avg 53µs/call | ||||
| 40 | 45 | 943µs | my ( $class, $name, %options ) = @_; | ||
| 41 | |||||
| 42 | (defined $name) | ||||
| 43 | || confess "You must provide a name for the attribute"; | ||||
| 44 | |||||
| 45 | return bless { | ||||
| 46 | name => $name, | ||||
| 47 | original_options => \%options, | ||||
| 48 | %options, | ||||
| 49 | }, $class; | ||||
| 50 | } | ||||
| 51 | |||||
| 52 | # spent 954µs (684+269) within Moose::Meta::Role::Attribute::attach_to_role which was called 15 times, avg 64µs/call:
# 15 times (684µs+269µs) by Moose::Meta::Role::_attach_attribute at line 253 of Moose/Meta/Role.pm, avg 64µs/call | ||||
| 53 | 45 | 988µs | my ( $self, $role ) = @_; | ||
| 54 | |||||
| 55 | 30 | 169µs | ( blessed($role) && $role->isa('Moose::Meta::Role') ) # spent 89µs making 15 calls to Scalar::Util::blessed, avg 6µs/call
# spent 80µs making 15 calls to UNIVERSAL::isa, avg 5µs/call | ||
| 56 | || confess | ||||
| 57 | "You must pass a Moose::Meta::Role instance (or a subclass)"; | ||||
| 58 | |||||
| 59 | 15 | 100µs | weaken( $self->{'associated_role'} = $role ); # spent 100µs making 15 calls to Scalar::Util::weaken, avg 7µs/call | ||
| 60 | } | ||||
| 61 | |||||
| 62 | # spent 13.4ms (424µs+12.9) within Moose::Meta::Role::Attribute::attribute_for_class which was called 7 times, avg 1.91ms/call:
# 7 times (424µs+12.9ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 142 of Moose/Meta/Role/Application/ToClass.pm, avg 1.91ms/call | ||||
| 63 | 21 | 483µs | my $self = shift; | ||
| 64 | my $metaclass = shift; | ||||
| 65 | |||||
| 66 | return $metaclass->interpolate_class_and_new( | ||||
| 67 | 21 | 5.21ms | $self->name => %{ $self->original_options } ); # spent 12.8ms making 7 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 1.83ms/call, recursion: max depth 1, sum of overlapping time 7.74ms
# spent 92µs making 7 calls to Moose::Meta::Role::Attribute::original_options, avg 13µs/call
# spent 42µs making 7 calls to Class::MOP::Mixin::AttributeCore::name, avg 6µs/call | ||
| 68 | } | ||||
| 69 | |||||
| 70 | # spent 1.11ms (526µs+588µs) within Moose::Meta::Role::Attribute::clone which was called 8 times, avg 139µs/call:
# 6 times (412µs+419µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 71 of Moose/Meta/Role/Application/ToRole.pm, avg 138µs/call
# 2 times (114µs+169µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 148 of Moose/Meta/Role/Application/RoleSummation.pm, avg 141µs/call | ||||
| 71 | 16 | 472µs | my $self = shift; | ||
| 72 | |||||
| 73 | 24 | 588µs | return ( ref $self )->new( $self->name, %{ $self->original_options } ); # spent 442µs making 8 calls to Moose::Meta::Role::Attribute::new, avg 55µs/call
# spent 101µs making 8 calls to Moose::Meta::Role::Attribute::original_options, avg 13µs/call
# spent 44µs making 8 calls to Class::MOP::Mixin::AttributeCore::name, avg 6µs/call | ||
| 74 | } | ||||
| 75 | |||||
| 76 | sub is_same_as { | ||||
| 77 | my $self = shift; | ||||
| 78 | my $attr = shift; | ||||
| 79 | |||||
| 80 | my $self_options = $self->original_options; | ||||
| 81 | my $other_options = $attr->original_options; | ||||
| 82 | |||||
| 83 | return 0 | ||||
| 84 | unless ( join q{|}, sort keys %{$self_options} ) eq ( join q{|}, sort keys %{$other_options} ); | ||||
| 85 | |||||
| 86 | for my $key ( keys %{$self_options} ) { | ||||
| 87 | return 0 if defined $self_options->{$key} && ! defined $other_options->{$key}; | ||||
| 88 | return 0 if ! defined $self_options->{$key} && defined $other_options->{$key}; | ||||
| 89 | |||||
| 90 | next if all { ! defined } $self_options->{$key}, $other_options->{$key}; | ||||
| 91 | |||||
| 92 | return 0 unless $self_options->{$key} eq $other_options->{$key}; | ||||
| 93 | } | ||||
| 94 | |||||
| 95 | return 1; | ||||
| 96 | } | ||||
| 97 | |||||
| 98 | 1 | 33µs | 1; | ||
| 99 | |||||
| 100 | =pod | ||||
| 101 | |||||
| - - |