Filename | /Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/Role/Application/ToClass.pm |
Statements | Executed 243 statements in 1.63ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
4 | 1 | 1 | 293µs | 35.2ms | apply_attributes | Moose::Meta::Role::Application::ToClass::
4 | 1 | 1 | 215µs | 3.70ms | apply_methods | Moose::Meta::Role::Application::ToClass::
4 | 1 | 1 | 99µs | 40.6ms | apply | Moose::Meta::Role::Application::ToClass::
12 | 3 | 1 | 66µs | 159µs | apply_method_modifiers | Moose::Meta::Role::Application::ToClass::
4 | 1 | 1 | 54µs | 727µs | check_role_exclusions | Moose::Meta::Role::Application::ToClass::
4 | 1 | 1 | 33µs | 68µs | check_required_methods | Moose::Meta::Role::Application::ToClass::
4 | 1 | 1 | 28µs | 68µs | apply_override_method_modifiers | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 15µs | 30µs | BEGIN@4 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 11µs | 32µs | BEGIN@10 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 11µs | 36µs | BEGIN@8 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 8µs | 32µs | BEGIN@12 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 8µs | 14µs | BEGIN@5 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 8µs | 159µs | BEGIN@9 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 8µs | 472µs | BEGIN@6 | Moose::Meta::Role::Application::ToClass::
4 | 1 | 1 | 6µs | 6µs | check_required_attributes | Moose::Meta::Role::Application::ToClass::
0 | 0 | 0 | 0s | 0s | __ANON__[:95] | Moose::Meta::Role::Application::ToClass::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Meta::Role::Application::ToClass; | ||||
2 | 1 | 700ns | our $VERSION = '2.1403'; | ||
3 | |||||
4 | 2 | 24µs | 2 | 46µs | # spent 30µs (15+15) within Moose::Meta::Role::Application::ToClass::BEGIN@4 which was called:
# once (15µs+15µs) by Moose::BEGIN@36 at line 4 # spent 30µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@4
# spent 15µs making 1 call to strict::import |
5 | 2 | 21µs | 2 | 20µs | # spent 14µs (8+6) within Moose::Meta::Role::Application::ToClass::BEGIN@5 which was called:
# once (8µs+6µs) by Moose::BEGIN@36 at line 5 # spent 14µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@5
# spent 6µs making 1 call to warnings::import |
6 | 2 | 32µs | 2 | 937µs | # spent 472µs (8+465) within Moose::Meta::Role::Application::ToClass::BEGIN@6 which was called:
# once (8µs+465µs) by Moose::BEGIN@36 at line 6 # spent 472µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@6
# spent 465µs making 1 call to metaclass::import |
7 | |||||
8 | 2 | 27µs | 2 | 61µs | # spent 36µs (11+25) within Moose::Meta::Role::Application::ToClass::BEGIN@8 which was called:
# once (11µs+25µs) by Moose::BEGIN@36 at line 8 # spent 36µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@8
# spent 25µs making 1 call to Exporter::import |
9 | 2 | 28µs | 2 | 311µs | # spent 159µs (8+152) within Moose::Meta::Role::Application::ToClass::BEGIN@9 which was called:
# once (8µs+152µs) by Moose::BEGIN@36 at line 9 # spent 159µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@9
# spent 152µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
10 | 2 | 25µs | 2 | 53µs | # spent 32µs (11+21) within Moose::Meta::Role::Application::ToClass::BEGIN@10 which was called:
# once (11µs+21µs) by Moose::BEGIN@36 at line 10 # spent 32µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@10
# spent 21µs making 1 call to Exporter::import |
11 | |||||
12 | 2 | 761µs | 2 | 55µs | # spent 32µs (8+23) within Moose::Meta::Role::Application::ToClass::BEGIN@12 which was called:
# once (8µs+23µs) by Moose::BEGIN@36 at line 12 # spent 32µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@12
# spent 23µs making 1 call to parent::import |
13 | |||||
14 | 1 | 7µs | 3 | 428µs | __PACKAGE__->meta->add_attribute('role' => ( # spent 404µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 18µs making 1 call to Moose::Meta::Role::Application::ToClass::meta
# spent 6µs making 1 call to Class::MOP::_definition_context |
15 | reader => 'role', | ||||
16 | Class::MOP::_definition_context(), | ||||
17 | )); | ||||
18 | |||||
19 | 1 | 5µs | 3 | 343µs | __PACKAGE__->meta->add_attribute('class' => ( # spent 326µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 12µs making 1 call to Moose::Meta::Role::Application::ToClass::meta
# spent 6µs making 1 call to Class::MOP::_definition_context |
20 | accessor => 'class', | ||||
21 | Class::MOP::_definition_context(), | ||||
22 | )); | ||||
23 | |||||
24 | # spent 40.6ms (99µs+40.5) within Moose::Meta::Role::Application::ToClass::apply which was called 4 times, avg 10.1ms/call:
# 4 times (99µs+40.5ms) by Moose::Meta::Role::apply at line 472 of Moose/Meta/Role.pm, avg 10.1ms/call | ||||
25 | 4 | 4µs | my ($self, $role, $class) = @_; | ||
26 | |||||
27 | # We need weak_ref in CMOP :( | ||||
28 | 4 | 14µs | 4 | 4µs | weaken($self->{role} = $role); # spent 4µs making 4 calls to Scalar::Util::weaken, avg 1µs/call |
29 | 4 | 21µs | 4 | 3µs | weaken($self->{class} = $class); # spent 3µs making 4 calls to Scalar::Util::weaken, avg 800ns/call |
30 | |||||
31 | 4 | 29µs | 4 | 40.3ms | $self->SUPER::apply($role, $class); # spent 40.3ms making 4 calls to Moose::Meta::Role::Application::apply, avg 10.1ms/call |
32 | |||||
33 | 4 | 11µs | 4 | 65µs | $class->add_role($role); # spent 65µs making 4 calls to Moose::Meta::Class::add_role, avg 16µs/call |
34 | 4 | 19µs | 4 | 64µs | $class->add_role_application($self); # spent 64µs making 4 calls to Moose::Meta::Class::add_role_application, avg 16µs/call |
35 | } | ||||
36 | |||||
37 | # spent 727µs (54+673) within Moose::Meta::Role::Application::ToClass::check_role_exclusions which was called 4 times, avg 182µs/call:
# 4 times (54µs+673µs) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 182µs/call | ||||
38 | 4 | 3µs | my ($self, $role, $class) = @_; | ||
39 | 4 | 24µs | 8 | 627µs | if ($class->excludes_role($role->name)) { # spent 624µs making 4 calls to Moose::Meta::Class::excludes_role, avg 156µs/call
# spent 3µs making 4 calls to Class::MOP::Package::name, avg 775ns/call |
40 | throw_exception( ConflictDetectedInCheckRoleExclusionsInToClass => class_name => $class->name, | ||||
41 | role_name => $role->name, | ||||
42 | ); | ||||
43 | } | ||||
44 | 4 | 24µs | 4 | 46µs | foreach my $excluded_role_name ($role->get_excluded_roles_list) { # spent 46µs making 4 calls to Moose::Meta::Role::get_excluded_roles_list, avg 12µs/call |
45 | if ($class->does_role($excluded_role_name)) { | ||||
46 | throw_exception( ClassDoesTheExcludedRole => role_name => $role->name, | ||||
47 | excluded_role_name => $excluded_role_name, | ||||
48 | class_name => $class->name, | ||||
49 | ); | ||||
50 | } | ||||
51 | } | ||||
52 | } | ||||
53 | |||||
54 | # spent 68µs (33+34) within Moose::Meta::Role::Application::ToClass::check_required_methods which was called 4 times, avg 17µs/call:
# 4 times (33µs+34µs) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 17µs/call | ||||
55 | 4 | 4µs | my ($self, $role, $class) = @_; | ||
56 | |||||
57 | 4 | 1µs | my @missing; | ||
58 | 4 | 400ns | my @is_attr; | ||
59 | |||||
60 | # NOTE: | ||||
61 | # we might need to move this down below the | ||||
62 | # the attributes so that we can require any | ||||
63 | # attribute accessors. However I am thinking | ||||
64 | # that maybe those are somehow exempt from | ||||
65 | # the require methods stuff. | ||||
66 | 4 | 12µs | 4 | 34µs | foreach my $required_method ($role->get_required_method_list) { # spent 34µs making 4 calls to Moose::Meta::Role::get_required_method_list, avg 9µs/call |
67 | my $required_method_name = $required_method->name; | ||||
68 | |||||
69 | if (!$class->find_method_by_name($required_method_name)) { | ||||
70 | |||||
71 | next if $self->is_aliased_method($required_method_name); | ||||
72 | |||||
73 | push @missing, $required_method; | ||||
74 | } | ||||
75 | } | ||||
76 | |||||
77 | 4 | 12µs | return unless @missing; | ||
78 | |||||
79 | my $error = ''; | ||||
80 | |||||
81 | @missing = sort { $a->name cmp $b->name } @missing; | ||||
82 | my @conflicts = grep { $_->isa('Moose::Meta::Role::Method::Conflicting') } @missing; | ||||
83 | |||||
84 | if (@conflicts) { | ||||
85 | my $conflict = $conflicts[0]; | ||||
86 | my $roles = $conflict->roles_as_english_list; | ||||
87 | |||||
88 | my @same_role_conflicts = grep { $_->roles_as_english_list eq $roles } @conflicts; | ||||
89 | |||||
90 | throw_exception( MethodNameConflictInRoles => conflict => \@same_role_conflicts, | ||||
91 | class_name => $class->name | ||||
92 | ); | ||||
93 | } | ||||
94 | elsif (@missing) { | ||||
95 | if (my $meth = firstval { $class->name->can($_) } @missing) { | ||||
96 | throw_exception( RequiredMethodsImportedByClass => class_name => $class->name, | ||||
97 | role_name => $role->name, | ||||
98 | missing_methods => \@missing, | ||||
99 | imported_method => $meth | ||||
100 | ); | ||||
101 | } | ||||
102 | else { | ||||
103 | throw_exception( RequiredMethodsNotImplementedByClass => class_name => $class->name, | ||||
104 | role_name => $role->name, | ||||
105 | missing_methods => \@missing, | ||||
106 | ); | ||||
107 | } | ||||
108 | } | ||||
109 | } | ||||
110 | |||||
111 | 4 | 11µs | # spent 6µs within Moose::Meta::Role::Application::ToClass::check_required_attributes which was called 4 times, avg 2µs/call:
# 4 times (6µs+0s) by Moose::Meta::Role::Application::apply at line 56 of Moose/Meta/Role/Application.pm, avg 2µs/call | ||
112 | |||||
113 | } | ||||
114 | |||||
115 | # spent 35.2ms (293µs+34.9) within Moose::Meta::Role::Application::ToClass::apply_attributes which was called 4 times, avg 8.81ms/call:
# 4 times (293µs+34.9ms) by Moose::Meta::Role::Application::apply at line 59 of Moose/Meta/Role/Application.pm, avg 8.81ms/call | ||||
116 | 4 | 3µs | my ($self, $role, $class) = @_; | ||
117 | |||||
118 | 4 | 27µs | 4 | 26µs | foreach my $attribute_name ($role->get_attribute_list) { # spent 26µs making 4 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 6µs/call |
119 | # it if it has one already | ||||
120 | 17 | 96µs | 17 | 97µs | if ($class->has_attribute($attribute_name) && # spent 97µs making 17 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 6µs/call |
121 | # make sure we haven't seen this one already too | ||||
122 | $class->get_attribute($attribute_name) != $role->get_attribute($attribute_name)) { | ||||
123 | next; | ||||
124 | } | ||||
125 | else { | ||||
126 | 17 | 93µs | 51 | 34.8ms | $class->add_attribute( # spent 27.4ms making 17 calls to Moose::Meta::Class::add_attribute, avg 1.61ms/call
# spent 7.33ms making 17 calls to Moose::Meta::Role::Attribute::attribute_for_class, avg 431µs/call
# spent 101µs making 17 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 6µs/call |
127 | $role->get_attribute($attribute_name)->attribute_for_class | ||||
128 | ); | ||||
129 | } | ||||
130 | } | ||||
131 | } | ||||
132 | |||||
133 | # spent 3.70ms (215µs+3.49) within Moose::Meta::Role::Application::ToClass::apply_methods which was called 4 times, avg 926µs/call:
# 4 times (215µs+3.49ms) by Moose::Meta::Role::Application::apply at line 60 of Moose/Meta/Role/Application.pm, avg 926µs/call | ||||
134 | 4 | 4µs | my ( $self, $role, $class ) = @_; | ||
135 | |||||
136 | 4 | 25µs | 4 | 2.44ms | foreach my $method ( $role->_get_local_methods ) { # spent 2.44ms making 4 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 609µs/call |
137 | 11 | 42µs | 11 | 9µs | my $method_name = $method->name; # spent 9µs making 11 calls to Class::MOP::Method::name, avg 818ns/call |
138 | |||||
139 | 11 | 42µs | 11 | 16µs | next if $method->isa('Class::MOP::Method::Meta'); # spent 16µs making 11 calls to UNIVERSAL::isa, avg 1µs/call |
140 | |||||
141 | 7 | 17µs | 7 | 62µs | unless ( $self->is_method_excluded($method_name) ) { # spent 62µs making 7 calls to Moose::Meta::Role::Application::is_method_excluded, avg 9µs/call |
142 | |||||
143 | 7 | 9µs | 7 | 332µs | my $class_method = $class->get_method($method_name); # spent 332µs making 7 calls to Class::MOP::Mixin::HasMethods::get_method, avg 47µs/call |
144 | |||||
145 | 7 | 9µs | 2 | 1µs | next if $class_method && $class_method->body != $method->body; # spent 1µs making 2 calls to Class::MOP::Method::body, avg 600ns/call |
146 | |||||
147 | 6 | 9µs | 6 | 574µs | $class->add_method( # spent 574µs making 6 calls to Class::MOP::Mixin::HasMethods::add_method, avg 96µs/call |
148 | $method_name, | ||||
149 | $method, | ||||
150 | ); | ||||
151 | } | ||||
152 | |||||
153 | 6 | 16µs | 6 | 48µs | next unless $self->is_method_aliased($method_name); # spent 48µs making 6 calls to Moose::Meta::Role::Application::is_method_aliased, avg 8µs/call |
154 | |||||
155 | my $aliased_method_name = $self->get_method_aliases->{$method_name}; | ||||
156 | |||||
157 | my $class_method = $class->get_method($aliased_method_name); | ||||
158 | |||||
159 | if ( $class_method && $class_method->body != $method->body ) { | ||||
160 | throw_exception( CannotCreateMethodAliasLocalMethodIsPresentInClass => aliased_method_name => $aliased_method_name, | ||||
161 | method => $method, | ||||
162 | role_name => $role->name, | ||||
163 | class_name => $class->name, | ||||
164 | ); | ||||
165 | } | ||||
166 | |||||
167 | $class->add_method( | ||||
168 | $aliased_method_name, | ||||
169 | $method, | ||||
170 | ); | ||||
171 | } | ||||
172 | |||||
173 | # we must reset the cache here since | ||||
174 | # we are just aliasing methods, otherwise | ||||
175 | # the modifiers go wonky. | ||||
176 | 4 | 23µs | 4 | 8µs | $class->reset_package_cache_flag; # spent 8µs making 4 calls to Class::MOP::Mixin::HasMethods::reset_package_cache_flag, avg 2µs/call |
177 | } | ||||
178 | |||||
179 | # spent 68µs (28+41) within Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers which was called 4 times, avg 17µs/call:
# 4 times (28µs+41µs) by Moose::Meta::Role::Application::apply at line 62 of Moose/Meta/Role/Application.pm, avg 17µs/call | ||||
180 | 4 | 4µs | my ($self, $role, $class) = @_; | ||
181 | 4 | 21µs | 4 | 41µs | foreach my $method_name ($role->get_method_modifier_list('override')) { # spent 41µs making 4 calls to Moose::Meta::Role::get_method_modifier_list, avg 10µs/call |
182 | # it if it has one already then ... | ||||
183 | if ($class->has_method($method_name)) { | ||||
184 | next; | ||||
185 | } | ||||
186 | else { | ||||
187 | # if this is not a role, then we need to | ||||
188 | # find the original package of the method | ||||
189 | # so that we can tell the class were to | ||||
190 | # find the right super() method | ||||
191 | my $method = $role->get_override_method_modifier($method_name); | ||||
192 | my ($package) = Class::MOP::get_code_info($method); | ||||
193 | # if it is a class, we just add it | ||||
194 | $class->add_override_method_modifier($method_name, $method, $package); | ||||
195 | } | ||||
196 | } | ||||
197 | } | ||||
198 | |||||
199 | # spent 159µs (66+93) within Moose::Meta::Role::Application::ToClass::apply_method_modifiers which was called 12 times, avg 13µs/call:
# 4 times (30µs+32µs) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 78 of Moose/Meta/Role/Application.pm, avg 16µs/call
# 4 times (18µs+31µs) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 79 of Moose/Meta/Role/Application.pm, avg 12µs/call
# 4 times (17µs+30µs) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 80 of Moose/Meta/Role/Application.pm, avg 12µs/call | ||||
200 | 12 | 9µs | my ($self, $modifier_type, $role, $class) = @_; | ||
201 | 12 | 6µs | my $add = "add_${modifier_type}_method_modifier"; | ||
202 | 12 | 4µs | my $get = "get_${modifier_type}_method_modifiers"; | ||
203 | 12 | 46µs | 12 | 93µs | foreach my $method_name ($role->get_method_modifier_list($modifier_type)) { # spent 93µs making 12 calls to Moose::Meta::Role::get_method_modifier_list, avg 8µs/call |
204 | $class->$add( | ||||
205 | $method_name, | ||||
206 | $_ | ||||
207 | ) foreach $role->$get($method_name); | ||||
208 | } | ||||
209 | } | ||||
210 | |||||
211 | 1 | 9µs | 1; | ||
212 | |||||
213 | # ABSTRACT: Compose a role into a class | ||||
214 | |||||
215 | __END__ |