Filename | /usr/local/lib/perl/5.18.2/Moose/Meta/Role/Application/ToClass.pm |
Statements | Executed 3309 statements in 10.1ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
28 | 1 | 1 | 7.17ms | 47.5ms | apply_methods | Moose::Meta::Role::Application::ToClass::
28 | 1 | 1 | 5.38ms | 13.4ms | apply_override_method_modifiers | Moose::Meta::Role::Application::ToClass::
28 | 1 | 1 | 870µs | 268ms | apply_attributes (recurses: max depth 1, inclusive time 2.62ms) | Moose::Meta::Role::Application::ToClass::
84 | 3 | 1 | 487µs | 5.70ms | apply_method_modifiers | Moose::Meta::Role::Application::ToClass::
28 | 1 | 1 | 406µs | 335ms | apply (recurses: max depth 1, inclusive time 14.2ms) | Moose::Meta::Role::Application::ToClass::
28 | 1 | 1 | 344µs | 2.89ms | check_required_methods | Moose::Meta::Role::Application::ToClass::
28 | 1 | 1 | 283µs | 5.28ms | check_role_exclusions | Moose::Meta::Role::Application::ToClass::
28 | 1 | 1 | 25µs | 25µs | check_required_attributes | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 11µs | 42µs | BEGIN@8 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 10µs | 23µs | BEGIN@4 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 8µs | 14µs | BEGIN@5 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 7µs | 28µs | BEGIN@12 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 6µs | 27µs | BEGIN@10 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 6µs | 150µs | BEGIN@9 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 6µs | 399µs | BEGIN@6 | 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 | 400ns | our $VERSION = '2.1604'; | ||
3 | |||||
4 | 2 | 21µs | 2 | 36µs | # spent 23µs (10+13) within Moose::Meta::Role::Application::ToClass::BEGIN@4 which was called:
# once (10µs+13µs) by Moose::BEGIN@36 at line 4 # spent 23µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@4
# spent 13µs making 1 call to strict::import |
5 | 2 | 20µs | 2 | 19µ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 | 29µs | 2 | 792µs | # spent 399µs (6+393) within Moose::Meta::Role::Application::ToClass::BEGIN@6 which was called:
# once (6µs+393µs) by Moose::BEGIN@36 at line 6 # spent 399µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@6
# spent 393µs making 1 call to metaclass::import |
7 | |||||
8 | 2 | 23µs | 2 | 50µs | # spent 42µs (11+32) within Moose::Meta::Role::Application::ToClass::BEGIN@8 which was called:
# once (11µs+32µs) by Moose::BEGIN@36 at line 8 # spent 42µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@8
# spent 8µs making 1 call to List::Util::import |
9 | 2 | 25µs | 2 | 293µs | # spent 150µs (6+143) within Moose::Meta::Role::Application::ToClass::BEGIN@9 which was called:
# once (6µs+143µs) by Moose::BEGIN@36 at line 9 # spent 150µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@9
# spent 143µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
10 | 2 | 23µs | 2 | 47µs | # spent 27µs (6+20) within Moose::Meta::Role::Application::ToClass::BEGIN@10 which was called:
# once (6µs+20µs) by Moose::BEGIN@36 at line 10 # spent 27µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@10
# spent 20µs making 1 call to Exporter::import |
11 | |||||
12 | 2 | 712µs | 2 | 49µs | # spent 28µs (7+21) within Moose::Meta::Role::Application::ToClass::BEGIN@12 which was called:
# once (7µs+21µs) by Moose::BEGIN@36 at line 12 # spent 28µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@12
# spent 21µs making 1 call to parent::import |
13 | |||||
14 | 1 | 6µs | 3 | 366µs | __PACKAGE__->meta->add_attribute('role' => ( # spent 344µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 15µs making 1 call to Moose::Meta::Role::Application::ToClass::meta
# spent 7µs making 1 call to Class::MOP::_definition_context |
15 | reader => 'role', | ||||
16 | Class::MOP::_definition_context(), | ||||
17 | )); | ||||
18 | |||||
19 | 1 | 3µs | 3 | 252µs | __PACKAGE__->meta->add_attribute('class' => ( # spent 240µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Moose::Meta::Role::Application::ToClass::meta
# spent 4µs making 1 call to Class::MOP::_definition_context |
20 | accessor => 'class', | ||||
21 | Class::MOP::_definition_context(), | ||||
22 | )); | ||||
23 | |||||
24 | # spent 335ms (406µs+334) within Moose::Meta::Role::Application::ToClass::apply which was called 28 times, avg 11.9ms/call:
# 28 times (406µs+334ms) by Moose::Meta::Role::apply at line 472 of Moose/Meta/Role.pm, avg 11.9ms/call | ||||
25 | 28 | 12µs | my ($self, $role, $class) = @_; | ||
26 | |||||
27 | # We need weak_ref in CMOP :( | ||||
28 | 28 | 91µs | 28 | 26µs | weaken($self->{role} = $role); # spent 26µs making 28 calls to Scalar::Util::weaken, avg 929ns/call |
29 | 28 | 67µs | 28 | 15µs | weaken($self->{class} = $class); # spent 15µs making 28 calls to Scalar::Util::weaken, avg 529ns/call |
30 | |||||
31 | 28 | 60µs | 28 | 333ms | $self->SUPER::apply($role, $class); # spent 348ms making 28 calls to Moose::Meta::Role::Application::apply, avg 12.4ms/call, recursion: max depth 1, sum of overlapping time 14.1ms |
32 | |||||
33 | 28 | 68µs | 28 | 360µs | $class->add_role($role); # spent 360µs making 28 calls to Moose::Meta::Class::add_role, avg 13µs/call |
34 | 28 | 103µs | 28 | 346µs | $class->add_role_application($self); # spent 346µs making 28 calls to Moose::Meta::Class::add_role_application, avg 12µs/call |
35 | } | ||||
36 | |||||
37 | # spent 5.28ms (283µs+5.00) within Moose::Meta::Role::Application::ToClass::check_role_exclusions which was called 28 times, avg 189µs/call:
# 28 times (283µs+5.00ms) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 189µs/call | ||||
38 | 28 | 12µs | my ($self, $role, $class) = @_; | ||
39 | 28 | 107µs | 56 | 4.83ms | if ($class->excludes_role($role->name)) { # spent 4.81ms making 28 calls to Moose::Meta::Class::excludes_role, avg 172µs/call
# spent 16µs making 14 calls to Moose::Meta::Role::Composite::name, avg 1µs/call
# spent 10µs making 14 calls to Class::MOP::Package::name, avg 700ns/call |
40 | throw_exception( ConflictDetectedInCheckRoleExclusionsInToClass => class_name => $class->name, | ||||
41 | role_name => $role->name, | ||||
42 | ); | ||||
43 | } | ||||
44 | 28 | 126µs | 28 | 166µs | foreach my $excluded_role_name ($role->get_excluded_roles_list) { # spent 166µs making 28 calls to Moose::Meta::Role::get_excluded_roles_list, avg 6µ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 2.89ms (344µs+2.55) within Moose::Meta::Role::Application::ToClass::check_required_methods which was called 28 times, avg 103µs/call:
# 28 times (344µs+2.55ms) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 103µs/call | ||||
55 | 28 | 10µs | my ($self, $role, $class) = @_; | ||
56 | |||||
57 | 28 | 4µs | my @missing; | ||
58 | 28 | 5µs | 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 | 28 | 68µs | 28 | 165µs | foreach my $required_method ($role->get_required_method_list) { # spent 165µs making 28 calls to Moose::Meta::Role::get_required_method_list, avg 6µs/call |
67 | 26 | 55µs | 26 | 61µs | my $required_method_name = $required_method->name; # spent 61µs making 26 calls to Moose::Meta::Role::Method::Required::name, avg 2µs/call |
68 | |||||
69 | 26 | 74µs | 52 | 2.32ms | if (!$class->find_method_by_name($required_method_name)) { # spent 2.30ms making 26 calls to Class::MOP::Class::find_method_by_name, avg 89µs/call
# spent 20µs making 26 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 762ns/call |
70 | |||||
71 | next if $self->is_aliased_method($required_method_name); | ||||
72 | |||||
73 | push @missing, $required_method; | ||||
74 | } | ||||
75 | } | ||||
76 | |||||
77 | 28 | 65µ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 = first { $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 | 28 | 59µs | # spent 25µs within Moose::Meta::Role::Application::ToClass::check_required_attributes which was called 28 times, avg 893ns/call:
# 28 times (25µs+0s) by Moose::Meta::Role::Application::apply at line 56 of Moose/Meta/Role/Application.pm, avg 893ns/call | ||
112 | |||||
113 | } | ||||
114 | |||||
115 | # spent 268ms (870µs+267) within Moose::Meta::Role::Application::ToClass::apply_attributes which was called 28 times, avg 9.57ms/call:
# 28 times (870µs+267ms) by Moose::Meta::Role::Application::apply at line 59 of Moose/Meta/Role/Application.pm, avg 9.57ms/call | ||||
116 | 28 | 12µs | my ($self, $role, $class) = @_; | ||
117 | |||||
118 | 28 | 127µs | 28 | 144µs | foreach my $attribute_name ($role->get_attribute_list) { # spent 144µs making 28 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 5µs/call |
119 | # it if it has one already | ||||
120 | 60 | 293µs | 60 | 266µs | if ($class->has_attribute($attribute_name) && # spent 266µs making 60 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 4µ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 | 60 | 248µs | 180 | 267ms | $class->add_attribute( # spent 190ms making 60 calls to Moose::Meta::Class::add_attribute, avg 3.17ms/call, recursion: max depth 1, sum of overlapping time 1.70ms
# spent 78.8ms making 60 calls to Moose::Meta::Role::Attribute::attribute_for_class, avg 1.31ms/call, recursion: max depth 1, sum of overlapping time 435µs
# spent 236µs making 60 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 4µs/call |
127 | $role->get_attribute($attribute_name)->attribute_for_class | ||||
128 | ); | ||||
129 | } | ||||
130 | } | ||||
131 | } | ||||
132 | |||||
133 | # spent 47.5ms (7.17+40.3) within Moose::Meta::Role::Application::ToClass::apply_methods which was called 28 times, avg 1.70ms/call:
# 28 times (7.17ms+40.3ms) by Moose::Meta::Role::Application::apply at line 60 of Moose/Meta/Role/Application.pm, avg 1.70ms/call | ||||
134 | 28 | 14µs | my ( $self, $role, $class ) = @_; | ||
135 | |||||
136 | 28 | 145µs | 28 | 16.4ms | foreach my $method ( $role->_get_local_methods ) { # spent 16.2ms making 14 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 1.16ms/call
# spent 126µs making 14 calls to Moose::Meta::Role::Composite::_get_local_methods, avg 9µs/call |
137 | 304 | 4.45ms | 304 | 152µs | my $method_name = $method->name; # spent 152µs making 304 calls to Class::MOP::Method::name, avg 499ns/call |
138 | |||||
139 | 304 | 804µs | 304 | 372µs | next if $method->isa('Class::MOP::Method::Meta'); # spent 372µs making 304 calls to UNIVERSAL::isa, avg 1µs/call |
140 | |||||
141 | 290 | 273µs | 290 | 1.16ms | unless ( $self->is_method_excluded($method_name) ) { # spent 1.16ms making 290 calls to Moose::Meta::Role::Application::is_method_excluded, avg 4µs/call |
142 | |||||
143 | 290 | 238µs | 290 | 4.71ms | my $class_method = $class->get_method($method_name); # spent 4.71ms making 290 calls to Class::MOP::Mixin::HasMethods::get_method, avg 16µs/call |
144 | |||||
145 | 290 | 59µs | 15 | 9µs | next if $class_method && $class_method->body != $method->body; # spent 6µs making 5 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 1µs/call
# spent 3µs making 10 calls to Class::MOP::Method::body, avg 340ns/call |
146 | |||||
147 | 285 | 276µs | 285 | 16.4ms | $class->add_method( # spent 16.4ms making 285 calls to Class::MOP::Mixin::HasMethods::add_method, avg 58µs/call |
148 | $method_name, | ||||
149 | $method, | ||||
150 | ); | ||||
151 | } | ||||
152 | |||||
153 | 285 | 387µs | 285 | 1.09ms | next unless $self->is_method_aliased($method_name); # spent 1.09ms making 285 calls to Moose::Meta::Role::Application::is_method_aliased, avg 4µ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 | 28 | 105µs | 28 | 43µs | $class->reset_package_cache_flag; # spent 43µs making 28 calls to Class::MOP::Mixin::HasMethods::reset_package_cache_flag, avg 2µs/call |
177 | } | ||||
178 | |||||
179 | # spent 13.4ms (5.38+8.06) within Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers which was called 28 times, avg 480µs/call:
# 28 times (5.38ms+8.06ms) by Moose::Meta::Role::Application::apply at line 62 of Moose/Meta/Role/Application.pm, avg 480µs/call | ||||
180 | 28 | 10µs | my ($self, $role, $class) = @_; | ||
181 | 28 | 146µs | 28 | 249µs | foreach my $method_name ($role->get_method_modifier_list('override')) { # spent 249µs making 28 calls to Moose::Meta::Role::get_method_modifier_list, avg 9µs/call |
182 | # it if it has one already then ... | ||||
183 | 24 | 42µs | 24 | 3.74ms | if ($class->has_method($method_name)) { # spent 3.74ms making 24 calls to Class::MOP::Mixin::HasMethods::has_method, avg 156µs/call |
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 | 24 | 29µs | 24 | 97µs | my $method = $role->get_override_method_modifier($method_name); # spent 97µs making 24 calls to Moose::Meta::Role::get_override_method_modifier, avg 4µs/call |
192 | 24 | 76µs | 24 | 29µs | my ($package) = Class::MOP::get_code_info($method); # spent 29µs making 24 calls to Class::MOP::get_code_info, avg 1µs/call |
193 | # if it is a class, we just add it | ||||
194 | 24 | 35µs | 24 | 3.95ms | $class->add_override_method_modifier($method_name, $method, $package); # spent 3.95ms making 24 calls to Moose::Meta::Class::add_override_method_modifier, avg 165µs/call |
195 | } | ||||
196 | } | ||||
197 | } | ||||
198 | |||||
199 | # spent 5.70ms (487µs+5.22) within Moose::Meta::Role::Application::ToClass::apply_method_modifiers which was called 84 times, avg 68µs/call:
# 28 times (198µs+3.90ms) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 79 of Moose/Meta/Role/Application.pm, avg 146µs/call
# 28 times (199µs+1.13ms) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 78 of Moose/Meta/Role/Application.pm, avg 48µs/call
# 28 times (89µs+187µs) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 80 of Moose/Meta/Role/Application.pm, avg 10µs/call | ||||
200 | 84 | 29µs | my ($self, $modifier_type, $role, $class) = @_; | ||
201 | 84 | 41µs | my $add = "add_${modifier_type}_method_modifier"; | ||
202 | 84 | 26µs | my $get = "get_${modifier_type}_method_modifiers"; | ||
203 | 84 | 257µs | 84 | 548µs | foreach my $method_name ($role->get_method_modifier_list($modifier_type)) { # spent 548µs making 84 calls to Moose::Meta::Role::get_method_modifier_list, avg 7µs/call |
204 | $class->$add( | ||||
205 | $method_name, | ||||
206 | $_ | ||||
207 | 23 | 110µs | 46 | 4.67ms | ) foreach $role->$get($method_name); # spent 3.63ms making 19 calls to Class::MOP::Class::add_around_method_modifier, avg 191µs/call
# spent 923µs making 4 calls to Class::MOP::Class::add_before_method_modifier, avg 231µs/call
# spent 97µs making 19 calls to Moose::Meta::Role::get_around_method_modifiers, avg 5µs/call
# spent 22µs making 4 calls to Moose::Meta::Role::get_before_method_modifiers, avg 6µs/call |
208 | } | ||||
209 | } | ||||
210 | |||||
211 | 1 | 4µs | 1; | ||
212 | |||||
213 | # ABSTRACT: Compose a role into a class | ||||
214 | |||||
215 | __END__ |