Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role/Attribute.pm |
Statements | Executed 477 statements in 1.44ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
38 | 2 | 2 | 244µs | 244µs | new | Moose::Meta::Role::Attribute::
38 | 1 | 1 | 196µs | 251µs | attach_to_role | Moose::Meta::Role::Attribute::
19 | 1 | 1 | 189µs | 32.8ms | attribute_for_class (recurses: max depth 1, inclusive time 472µs) | Moose::Meta::Role::Attribute::
19 | 2 | 2 | 141µs | 391µs | clone | Moose::Meta::Role::Attribute::
38 | 2 | 1 | 109µs | 170µs | original_role | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 8µs | 18µs | BEGIN@9 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 8µs | 8µs | BEGIN@2 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 6µs | 23µs | BEGIN@13 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 6µs | 25µs | BEGIN@12 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 6µs | 9µs | BEGIN@10 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 6µs | 26µs | BEGIN@14 | Moose::Meta::Role::Attribute::
1 | 1 | 1 | 6µs | 93µs | BEGIN@16 | Moose::Meta::Role::Attribute::
0 | 0 | 0 | 0s | 0s | __ANON__[:120] | Moose::Meta::Role::Attribute::
0 | 0 | 0 | 0s | 0s | is_same_as | Moose::Meta::Role::Attribute::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Meta::Role::Attribute; | ||||
2 | # spent 8µs within Moose::Meta::Role::Attribute::BEGIN@2 which was called:
# once (8µs+0s) by Moose::Meta::Role::BEGIN@19 at line 4 | ||||
3 | 1 | 4µs | $Moose::Meta::Role::Attribute::AUTHORITY = 'cpan:STEVAN'; | ||
4 | 1 | 28µs | 1 | 8µs | } # spent 8µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@2 |
5 | { | ||||
6 | 2 | 700ns | $Moose::Meta::Role::Attribute::VERSION = '2.1005'; | ||
7 | } | ||||
8 | |||||
9 | 2 | 19µs | 2 | 28µs | # spent 18µs (8+10) within Moose::Meta::Role::Attribute::BEGIN@9 which was called:
# once (8µs+10µs) by Moose::Meta::Role::BEGIN@19 at line 9 # spent 18µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@9
# spent 10µs making 1 call to strict::import |
10 | 2 | 20µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::Role::Attribute::BEGIN@10 which was called:
# once (6µs+3µs) by Moose::Meta::Role::BEGIN@19 at line 10 # spent 9µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@10
# spent 3µs making 1 call to warnings::import |
11 | |||||
12 | 2 | 20µs | 2 | 44µs | # spent 25µs (6+19) within Moose::Meta::Role::Attribute::BEGIN@12 which was called:
# once (6µs+19µs) by Moose::Meta::Role::BEGIN@19 at line 12 # spent 25µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@12
# spent 19µs making 1 call to Exporter::import |
13 | 2 | 21µs | 2 | 40µs | # spent 23µs (6+17) within Moose::Meta::Role::Attribute::BEGIN@13 which was called:
# once (6µs+17µs) by Moose::Meta::Role::BEGIN@19 at line 13 # spent 23µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@13
# spent 17µs making 1 call to Exporter::import |
14 | 2 | 22µs | 2 | 45µs | # spent 26µs (6+20) within Moose::Meta::Role::Attribute::BEGIN@14 which was called:
# once (6µs+20µs) by Moose::Meta::Role::BEGIN@19 at line 14 # spent 26µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@14
# spent 20µs making 1 call to Exporter::import |
15 | |||||
16 | 2 | 403µs | 2 | 180µs | # spent 93µs (6+87) within Moose::Meta::Role::Attribute::BEGIN@16 which was called:
# once (6µs+87µs) by Moose::Meta::Role::BEGIN@19 at line 16 # spent 93µs making 1 call to Moose::Meta::Role::Attribute::BEGIN@16
# spent 87µs making 1 call to base::import |
17 | |||||
18 | 1 | 6µs | 3 | 616µs | __PACKAGE__->meta->add_attribute( # spent 350µs making 1 call to Class::MOP::Mixin::meta
# spent 262µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 5µs making 1 call to Class::MOP::_definition_context |
19 | 'metaclass' => ( | ||||
20 | reader => 'metaclass', | ||||
21 | Class::MOP::_definition_context(), | ||||
22 | ) | ||||
23 | ); | ||||
24 | |||||
25 | 1 | 3µs | 3 | 263µs | __PACKAGE__->meta->add_attribute( # spent 250µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 9µs making 1 call to Class::MOP::Mixin::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
26 | 'associated_role' => ( | ||||
27 | reader => 'associated_role', | ||||
28 | Class::MOP::_definition_context(), | ||||
29 | ) | ||||
30 | ); | ||||
31 | |||||
32 | 1 | 3µs | 3 | 260µs | __PACKAGE__->meta->add_attribute( # spent 248µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Class::MOP::Mixin::meta
# spent 4µs making 1 call to Class::MOP::_definition_context |
33 | '_original_role' => ( | ||||
34 | reader => '_original_role', | ||||
35 | Class::MOP::_definition_context(), | ||||
36 | ) | ||||
37 | ); | ||||
38 | |||||
39 | 1 | 3µs | 3 | 256µs | __PACKAGE__->meta->add_attribute( # spent 244µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Class::MOP::Mixin::meta
# spent 4µs making 1 call to Class::MOP::_definition_context |
40 | 'is' => ( | ||||
41 | reader => 'is', | ||||
42 | Class::MOP::_definition_context(), | ||||
43 | ) | ||||
44 | ); | ||||
45 | |||||
46 | 1 | 3µs | 3 | 255µs | __PACKAGE__->meta->add_attribute( # spent 242µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Class::MOP::Mixin::meta
# spent 4µs making 1 call to Class::MOP::_definition_context |
47 | 'original_options' => ( | ||||
48 | reader => 'original_options', | ||||
49 | Class::MOP::_definition_context(), | ||||
50 | ) | ||||
51 | ); | ||||
52 | |||||
53 | # spent 244µs within Moose::Meta::Role::Attribute::new which was called 38 times, avg 6µs/call:
# 19 times (126µs+0s) by Class::MOP::Mixin::HasAttributes::add_attribute at line 20 of Class/MOP/Mixin/HasAttributes.pm, avg 7µs/call
# 19 times (118µs+0s) by Moose::Meta::Role::Attribute::clone at line 101, avg 6µs/call | ||||
54 | 38 | 58µs | my ( $class, $name, %options ) = @_; | ||
55 | |||||
56 | 38 | 4µs | (defined $name) | ||
57 | || confess "You must provide a name for the attribute"; | ||||
58 | |||||
59 | 38 | 11µs | my $role = delete $options{_original_role}; | ||
60 | |||||
61 | 38 | 196µs | return bless { | ||
62 | name => $name, | ||||
63 | original_options => \%options, | ||||
64 | _original_role => $role, | ||||
65 | %options, | ||||
66 | }, $class; | ||||
67 | } | ||||
68 | |||||
69 | # spent 251µs (196+55) within Moose::Meta::Role::Attribute::attach_to_role which was called 38 times, avg 7µs/call:
# 38 times (196µs+55µs) by Moose::Meta::Role::_attach_attribute at line 259 of Moose/Meta/Role.pm, avg 7µs/call | ||||
70 | 38 | 3µs | my ( $self, $role ) = @_; | ||
71 | |||||
72 | 38 | 135µs | 76 | 33µs | ( blessed($role) && $role->isa('Moose::Meta::Role') ) # spent 17µs making 38 calls to Scalar::Util::blessed, avg 447ns/call
# spent 16µs making 38 calls to UNIVERSAL::isa, avg 413ns/call |
73 | || confess | ||||
74 | "You must pass a Moose::Meta::Role instance (or a subclass)"; | ||||
75 | |||||
76 | 38 | 131µs | 38 | 22µs | weaken( $self->{'associated_role'} = $role ); # spent 22µs making 38 calls to Scalar::Util::weaken, avg 576ns/call |
77 | } | ||||
78 | |||||
79 | # spent 170µs (109+62) within Moose::Meta::Role::Attribute::original_role which was called 38 times, avg 4µs/call:
# 19 times (66µs+37µs) by Moose::Meta::Role::Attribute::clone at line 97, avg 5µs/call
# 19 times (43µs+25µs) by Moose::Meta::Role::Attribute::attribute_for_class at line 88, avg 4µs/call | ||||
80 | 38 | 2µs | my $self = shift; | ||
81 | |||||
82 | 38 | 84µs | 57 | 62µs | return $self->_original_role || $self->associated_role; # spent 43µs making 38 calls to Moose::Meta::Role::Attribute::_original_role, avg 1µs/call
# spent 18µs making 19 calls to Moose::Meta::Role::Attribute::associated_role, avg 974ns/call |
83 | } | ||||
84 | |||||
85 | # spent 32.8ms (189µs+32.6) within Moose::Meta::Role::Attribute::attribute_for_class which was called 19 times, avg 1.73ms/call:
# 19 times (189µs+32.6ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 152 of Moose/Meta/Role/Application/ToClass.pm, avg 1.73ms/call | ||||
86 | 19 | 2µs | my $self = shift; | ||
87 | |||||
88 | 19 | 30µs | 38 | 93µs | my $metaclass = $self->original_role->applied_attribute_metaclass; # spent 67µs making 19 calls to Moose::Meta::Role::Attribute::original_role, avg 4µs/call
# spent 26µs making 19 calls to Moose::Meta::Role::applied_attribute_metaclass, avg 1µs/call |
89 | |||||
90 | return $metaclass->interpolate_class_and_new( | ||||
91 | 19 | 113µs | 57 | 32.5ms | $self->name => %{ $self->original_options } ); # spent 32.9ms making 19 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 1.73ms/call, recursion: max depth 1, sum of overlapping time 440µs
# spent 22µs making 19 calls to Moose::Meta::Role::Attribute::original_options, avg 1µs/call
# spent 10µs making 19 calls to Class::MOP::Mixin::AttributeCore::name, avg 547ns/call |
92 | } | ||||
93 | |||||
94 | # spent 391µs (141+250) within Moose::Meta::Role::Attribute::clone which was called 19 times, avg 21µs/call:
# 17 times (126µs+222µs) by Moose::Meta::Role::Application::RoleSummation::apply_attributes at line 151 of Moose/Meta/Role/Application/RoleSummation.pm, avg 20µs/call
# 2 times (16µs+27µs) by Moose::Meta::Role::Application::ToRole::apply_attributes at line 73 of Moose/Meta/Role/Application/ToRole.pm, avg 21µs/call | ||||
95 | 19 | 2µs | my $self = shift; | ||
96 | |||||
97 | 19 | 10µs | 19 | 103µs | my $role = $self->original_role; # spent 103µs making 19 calls to Moose::Meta::Role::Attribute::original_role, avg 5µs/call |
98 | |||||
99 | return ( ref $self )->new( | ||||
100 | $self->name, | ||||
101 | 19 | 96µs | 57 | 146µs | %{ $self->original_options }, # spent 118µs making 19 calls to Moose::Meta::Role::Attribute::new, avg 6µs/call
# spent 20µs making 19 calls to Moose::Meta::Role::Attribute::original_options, avg 1µs/call
# spent 9µs making 19 calls to Class::MOP::Mixin::AttributeCore::name, avg 463ns/call |
102 | _original_role => $role, | ||||
103 | ); | ||||
104 | } | ||||
105 | |||||
106 | sub is_same_as { | ||||
107 | my $self = shift; | ||||
108 | my $attr = shift; | ||||
109 | |||||
110 | my $self_options = $self->original_options; | ||||
111 | my $other_options = $attr->original_options; | ||||
112 | |||||
113 | return 0 | ||||
114 | unless ( join q{|}, sort keys %{$self_options} ) eq ( join q{|}, sort keys %{$other_options} ); | ||||
115 | |||||
116 | for my $key ( keys %{$self_options} ) { | ||||
117 | return 0 if defined $self_options->{$key} && ! defined $other_options->{$key}; | ||||
118 | return 0 if ! defined $self_options->{$key} && defined $other_options->{$key}; | ||||
119 | |||||
120 | next if all { ! defined } $self_options->{$key}, $other_options->{$key}; | ||||
121 | |||||
122 | return 0 unless $self_options->{$key} eq $other_options->{$key}; | ||||
123 | } | ||||
124 | |||||
125 | return 1; | ||||
126 | } | ||||
127 | |||||
128 | 1 | 7µs | 1; | ||
129 | |||||
130 | # ABSTRACT: The Moose attribute metaclass for Roles | ||||
131 | |||||
132 | __END__ |