Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role/Application/ToClass.pm |
Statements | Executed 1925 statements in 3.51ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
10 | 1 | 1 | 2.17ms | 32.7ms | apply_methods | Moose::Meta::Role::Application::ToClass::
30 | 3 | 1 | 272µs | 4.76ms | apply_method_modifiers | Moose::Meta::Role::Application::ToClass::
10 | 1 | 1 | 230µs | 232ms | apply_attributes (recurses: max depth 1, inclusive time 8.01ms) | Moose::Meta::Role::Application::ToClass::
10 | 1 | 1 | 210µs | 4.24ms | apply_override_method_modifiers | Moose::Meta::Role::Application::ToClass::
10 | 1 | 1 | 116µs | 240ms | apply (recurses: max depth 1, inclusive time 45.1ms) | Moose::Meta::Role::Application::ToClass::
10 | 1 | 1 | 76µs | 2.16ms | check_role_exclusions | Moose::Meta::Role::Application::ToClass::
10 | 1 | 1 | 73µs | 444µs | check_required_methods | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 19µs | 40µs | BEGIN@13 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 9µs | 9µs | BEGIN@2 | Moose::Meta::Role::Application::ToClass::
10 | 1 | 1 | 8µs | 8µs | check_required_attributes | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 6µs | 30µs | BEGIN@15 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 6µs | 122µs | BEGIN@14 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 6µs | 9µs | BEGIN@10 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 6µs | 16µs | BEGIN@9 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 6µs | 51µs | BEGIN@17 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 6µs | 2.95ms | BEGIN@11 | Moose::Meta::Role::Application::ToClass::
0 | 0 | 0 | 0s | 0s | __ANON__[:127] | Moose::Meta::Role::Application::ToClass::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Meta::Role::Application::ToClass; | ||||
2 | # spent 9µs within Moose::Meta::Role::Application::ToClass::BEGIN@2 which was called:
# once (9µs+0s) by Moose::BEGIN@39 at line 4 | ||||
3 | 1 | 8µs | $Moose::Meta::Role::Application::ToClass::AUTHORITY = 'cpan:STEVAN'; | ||
4 | 1 | 28µs | 1 | 9µs | } # spent 9µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@2 |
5 | { | ||||
6 | 2 | 800ns | $Moose::Meta::Role::Application::ToClass::VERSION = '2.1005'; | ||
7 | } | ||||
8 | |||||
9 | 2 | 20µs | 2 | 26µs | # spent 16µs (6+10) within Moose::Meta::Role::Application::ToClass::BEGIN@9 which was called:
# once (6µs+10µs) by Moose::BEGIN@39 at line 9 # spent 16µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@9
# spent 10µs making 1 call to strict::import |
10 | 2 | 19µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::Role::Application::ToClass::BEGIN@10 which was called:
# once (6µs+3µs) by Moose::BEGIN@39 at line 10 # spent 9µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@10
# spent 3µs making 1 call to warnings::import |
11 | 2 | 27µs | 2 | 5.90ms | # spent 2.95ms (6µs+2.95) within Moose::Meta::Role::Application::ToClass::BEGIN@11 which was called:
# once (6µs+2.95ms) by Moose::BEGIN@39 at line 11 # spent 2.95ms making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@11
# spent 2.95ms making 1 call to metaclass::import |
12 | |||||
13 | 2 | 24µs | 2 | 62µs | # spent 40µs (19+21) within Moose::Meta::Role::Application::ToClass::BEGIN@13 which was called:
# once (19µs+21µs) by Moose::BEGIN@39 at line 13 # spent 40µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@13
# spent 21µs making 1 call to Exporter::import |
14 | 2 | 27µs | 2 | 238µs | # spent 122µs (6+116) within Moose::Meta::Role::Application::ToClass::BEGIN@14 which was called:
# once (6µs+116µs) by Moose::BEGIN@39 at line 14 # spent 122µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@14
# spent 116µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
15 | 2 | 24µs | 2 | 54µs | # spent 30µs (6+24) within Moose::Meta::Role::Application::ToClass::BEGIN@15 which was called:
# once (6µs+24µs) by Moose::BEGIN@39 at line 15 # spent 30µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@15
# spent 24µs making 1 call to Exporter::import |
16 | |||||
17 | 2 | 860µs | 2 | 97µs | # spent 51µs (6+45) within Moose::Meta::Role::Application::ToClass::BEGIN@17 which was called:
# once (6µs+45µs) by Moose::BEGIN@39 at line 17 # spent 51µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@17
# spent 45µs making 1 call to base::import |
18 | |||||
19 | 1 | 4µs | 3 | 291µs | __PACKAGE__->meta->add_attribute('role' => ( # spent 272µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 14µs making 1 call to Moose::Meta::Role::Application::ToClass::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
20 | reader => 'role', | ||||
21 | Class::MOP::_definition_context(), | ||||
22 | )); | ||||
23 | |||||
24 | 1 | 3µs | 3 | 269µs | __PACKAGE__->meta->add_attribute('class' => ( # spent 256µ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 5µs making 1 call to Class::MOP::_definition_context |
25 | accessor => 'class', | ||||
26 | Class::MOP::_definition_context(), | ||||
27 | )); | ||||
28 | |||||
29 | # spent 240ms (116µs+240) within Moose::Meta::Role::Application::ToClass::apply which was called 10 times, avg 24.0ms/call:
# 10 times (116µs+240ms) by Moose::Meta::Role::apply at line 470 of Moose/Meta/Role.pm, avg 24.0ms/call | ||||
30 | 10 | 3µs | my ($self, $role, $class) = @_; | ||
31 | |||||
32 | # We need weak_ref in CMOP :( | ||||
33 | 10 | 26µs | 10 | 7µs | weaken($self->{role} = $role); # spent 7µs making 10 calls to Scalar::Util::weaken, avg 710ns/call |
34 | 10 | 21µs | 10 | 6µs | weaken($self->{class} = $class); # spent 6µs making 10 calls to Scalar::Util::weaken, avg 550ns/call |
35 | |||||
36 | 10 | 14µs | 10 | 240ms | $self->SUPER::apply($role, $class); # spent 285ms making 10 calls to Moose::Meta::Role::Application::apply, avg 28.5ms/call, recursion: max depth 1, sum of overlapping time 44.9ms |
37 | |||||
38 | 10 | 13µs | 10 | 93µs | $class->add_role($role); # spent 93µs making 10 calls to Moose::Meta::Class::add_role, avg 9µs/call |
39 | 10 | 25µs | 10 | 95µs | $class->add_role_application($self); # spent 95µs making 10 calls to Moose::Meta::Class::add_role_application, avg 10µs/call |
40 | } | ||||
41 | |||||
42 | # spent 2.16ms (76µs+2.09) within Moose::Meta::Role::Application::ToClass::check_role_exclusions which was called 10 times, avg 216µs/call:
# 10 times (76µs+2.09ms) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 216µs/call | ||||
43 | 10 | 2µs | my ($self, $role, $class) = @_; | ||
44 | 10 | 32µs | 20 | 2.04ms | if ($class->excludes_role($role->name)) { # spent 2.03ms making 10 calls to Moose::Meta::Class::excludes_role, avg 203µs/call
# spent 5µs making 9 calls to Class::MOP::Package::name, avg 556ns/call
# spent 1µs making 1 call to Moose::Meta::Role::Composite::name |
45 | $class->throw_error("Conflict detected: " . $class->name . " excludes role '" . $role->name . "'"); | ||||
46 | } | ||||
47 | 10 | 35µs | 10 | 48µs | foreach my $excluded_role_name ($role->get_excluded_roles_list) { # spent 48µs making 10 calls to Moose::Meta::Role::get_excluded_roles_list, avg 5µs/call |
48 | if ($class->does_role($excluded_role_name)) { | ||||
49 | $class->throw_error("The class " . $class->name . " does the excluded role '$excluded_role_name'"); | ||||
50 | } | ||||
51 | } | ||||
52 | } | ||||
53 | |||||
54 | # spent 444µs (73+371) within Moose::Meta::Role::Application::ToClass::check_required_methods which was called 10 times, avg 44µs/call:
# 10 times (73µs+371µs) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 44µs/call | ||||
55 | 10 | 3µs | my ($self, $role, $class) = @_; | ||
56 | |||||
57 | 10 | 2µs | my @missing; | ||
58 | 10 | 800ns | 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 | 10 | 15µs | 10 | 43µs | foreach my $required_method ($role->get_required_method_list) { # spent 43µs making 10 calls to Moose::Meta::Role::get_required_method_list, avg 4µs/call |
67 | 4 | 5µs | 4 | 6µs | my $required_method_name = $required_method->name; # spent 6µs making 4 calls to Moose::Meta::Role::Method::Required::name, avg 1µs/call |
68 | |||||
69 | 4 | 8µs | 4 | 323µs | if (!$class->find_method_by_name($required_method_name)) { # spent 323µs making 4 calls to Class::MOP::Class::find_method_by_name, avg 81µs/call |
70 | |||||
71 | next if $self->is_aliased_method($required_method_name); | ||||
72 | |||||
73 | push @missing, $required_method; | ||||
74 | } | ||||
75 | } | ||||
76 | |||||
77 | 10 | 28µ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 | if (@same_role_conflicts == 1) { | ||||
91 | $error | ||||
92 | .= "Due to a method name conflict in roles " | ||||
93 | . $roles | ||||
94 | . ", the method '" | ||||
95 | . $conflict->name | ||||
96 | . "' must be implemented or excluded by '" | ||||
97 | . $class->name | ||||
98 | . q{'}; | ||||
99 | } | ||||
100 | else { | ||||
101 | my $methods | ||||
102 | = Moose::Util::english_list( map { q{'} . $_->name . q{'} } @same_role_conflicts ); | ||||
103 | |||||
104 | $error | ||||
105 | .= "Due to method name conflicts in roles " | ||||
106 | . $roles | ||||
107 | . ", the methods " | ||||
108 | . $methods | ||||
109 | . " must be implemented or excluded by '" | ||||
110 | . $class->name | ||||
111 | . q{'}; | ||||
112 | } | ||||
113 | } | ||||
114 | elsif (@missing) { | ||||
115 | my $noun = @missing == 1 ? 'method' : 'methods'; | ||||
116 | |||||
117 | my $list | ||||
118 | = Moose::Util::english_list( map { q{'} . $_ . q{'} } @missing ); | ||||
119 | |||||
120 | $error | ||||
121 | .= q{'} | ||||
122 | . $role->name | ||||
123 | . "' requires the $noun $list " | ||||
124 | . "to be implemented by '" | ||||
125 | . $class->name . q{'}; | ||||
126 | |||||
127 | if (my $meth = firstval { $class->name->can($_) } @missing) { | ||||
128 | $error .= ". If you imported functions intending to use them as " | ||||
129 | . "methods, you need to explicitly mark them as such, via " | ||||
130 | . $class->name . "->meta->add_method($meth => \\\&$meth)"; | ||||
131 | } | ||||
132 | } | ||||
133 | |||||
134 | $class->throw_error($error); | ||||
135 | } | ||||
136 | |||||
137 | 10 | 14µs | # spent 8µs within Moose::Meta::Role::Application::ToClass::check_required_attributes which was called 10 times, avg 830ns/call:
# 10 times (8µs+0s) by Moose::Meta::Role::Application::apply at line 56 of Moose/Meta/Role/Application.pm, avg 830ns/call | ||
138 | |||||
139 | } | ||||
140 | |||||
141 | # spent 232ms (230µs+232) within Moose::Meta::Role::Application::ToClass::apply_attributes which was called 10 times, avg 23.2ms/call:
# 10 times (230µs+232ms) by Moose::Meta::Role::Application::apply at line 58 of Moose/Meta/Role/Application.pm, avg 23.2ms/call | ||||
142 | 10 | 3µs | my ($self, $role, $class) = @_; | ||
143 | |||||
144 | 10 | 34µs | 10 | 36µs | foreach my $attribute_name ($role->get_attribute_list) { # spent 36µs making 10 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 4µs/call |
145 | # it if it has one already | ||||
146 | 19 | 59µs | 19 | 74µs | if ($class->has_attribute($attribute_name) && # spent 74µs making 19 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 4µs/call |
147 | # make sure we haven't seen this one already too | ||||
148 | $class->get_attribute($attribute_name) != $role->get_attribute($attribute_name)) { | ||||
149 | next; | ||||
150 | } | ||||
151 | else { | ||||
152 | 19 | 55µs | 57 | 239ms | $class->add_attribute( # spent 207ms making 19 calls to Moose::Meta::Class::add_attribute, avg 10.9ms/call
# spent 33.3ms making 19 calls to Moose::Meta::Role::Attribute::attribute_for_class, avg 1.75ms/call, recursion: max depth 1, sum of overlapping time 472µs
# spent 60µs making 19 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 3µs/call |
153 | $role->get_attribute($attribute_name)->attribute_for_class | ||||
154 | ); | ||||
155 | } | ||||
156 | } | ||||
157 | } | ||||
158 | |||||
159 | # spent 32.7ms (2.17+30.5) within Moose::Meta::Role::Application::ToClass::apply_methods which was called 10 times, avg 3.27ms/call:
# 10 times (2.17ms+30.5ms) by Moose::Meta::Role::Application::apply at line 59 of Moose/Meta/Role/Application.pm, avg 3.27ms/call | ||||
160 | 10 | 2µs | my ( $self, $role, $class ) = @_; | ||
161 | |||||
162 | 10 | 45µs | 10 | 3.34ms | foreach my $method ( $role->_get_local_methods ) { # spent 3.33ms making 9 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 371µs/call
# spent 10µs making 1 call to Moose::Meta::Role::Composite::_get_local_methods |
163 | 208 | 455µs | 208 | 109µs | my $method_name = $method->name; # spent 109µs making 208 calls to Class::MOP::Method::name, avg 523ns/call |
164 | |||||
165 | 208 | 485µs | 208 | 216µs | next if $method->isa('Class::MOP::Method::Meta'); # spent 216µs making 208 calls to UNIVERSAL::isa, avg 1µs/call |
166 | |||||
167 | 199 | 152µs | 199 | 818µs | unless ( $self->is_method_excluded($method_name) ) { # spent 818µs making 199 calls to Moose::Meta::Role::Application::is_method_excluded, avg 4µs/call |
168 | |||||
169 | 199 | 144µs | 199 | 8.75ms | my $class_method = $class->get_method($method_name); # spent 8.75ms making 199 calls to Class::MOP::Mixin::HasMethods::get_method, avg 44µs/call |
170 | |||||
171 | 199 | 400ns | next if $class_method && $class_method->body != $method->body; | ||
172 | |||||
173 | 199 | 173µs | 199 | 16.5ms | $class->add_method( # spent 16.5ms making 199 calls to Class::MOP::Mixin::HasMethods::add_method, avg 83µs/call |
174 | $method_name, | ||||
175 | $method, | ||||
176 | ); | ||||
177 | } | ||||
178 | |||||
179 | 199 | 217µs | 199 | 752µs | next unless $self->is_method_aliased($method_name); # spent 752µs making 199 calls to Moose::Meta::Role::Application::is_method_aliased, avg 4µs/call |
180 | |||||
181 | my $aliased_method_name = $self->get_method_aliases->{$method_name}; | ||||
182 | |||||
183 | my $class_method = $class->get_method($aliased_method_name); | ||||
184 | |||||
185 | if ( $class_method && $class_method->body != $method->body ) { | ||||
186 | $class->throw_error( | ||||
187 | "Cannot create a method alias if a local method of the same name exists" | ||||
188 | ); | ||||
189 | } | ||||
190 | |||||
191 | $class->add_method( | ||||
192 | $aliased_method_name, | ||||
193 | $method, | ||||
194 | ); | ||||
195 | } | ||||
196 | |||||
197 | # we must reset the cache here since | ||||
198 | # we are just aliasing methods, otherwise | ||||
199 | # the modifiers go wonky. | ||||
200 | 10 | 27µs | 10 | 10µs | $class->reset_package_cache_flag; # spent 10µs making 10 calls to Class::MOP::Mixin::HasMethods::reset_package_cache_flag, avg 1µs/call |
201 | } | ||||
202 | |||||
203 | # spent 4.24ms (210µs+4.03) within Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers which was called 10 times, avg 424µs/call:
# 10 times (210µs+4.03ms) by Moose::Meta::Role::Application::apply at line 61 of Moose/Meta/Role/Application.pm, avg 424µs/call | ||||
204 | 10 | 3µs | my ($self, $role, $class) = @_; | ||
205 | 10 | 30µs | 10 | 57µs | foreach my $method_name ($role->get_method_modifier_list('override')) { # spent 57µs making 10 calls to Moose::Meta::Role::get_method_modifier_list, avg 6µs/call |
206 | # it if it has one already then ... | ||||
207 | 21 | 27µs | 21 | 669µs | if ($class->has_method($method_name)) { # spent 669µs making 21 calls to Class::MOP::Mixin::HasMethods::has_method, avg 32µs/call |
208 | next; | ||||
209 | } | ||||
210 | else { | ||||
211 | # if this is not a role, then we need to | ||||
212 | # find the original package of the method | ||||
213 | # so that we can tell the class were to | ||||
214 | # find the right super() method | ||||
215 | 21 | 18µs | 21 | 82µs | my $method = $role->get_override_method_modifier($method_name); # spent 82µs making 21 calls to Moose::Meta::Role::get_override_method_modifier, avg 4µs/call |
216 | 21 | 62µs | 21 | 24µs | my ($package) = Class::MOP::get_code_info($method); # spent 24µs making 21 calls to Class::MOP::get_code_info, avg 1µs/call |
217 | # if it is a class, we just add it | ||||
218 | 21 | 23µs | 21 | 3.20ms | $class->add_override_method_modifier($method_name, $method, $package); # spent 3.20ms making 21 calls to Moose::Meta::Class::add_override_method_modifier, avg 152µs/call |
219 | } | ||||
220 | } | ||||
221 | } | ||||
222 | |||||
223 | # spent 4.76ms (272µs+4.49) within Moose::Meta::Role::Application::ToClass::apply_method_modifiers which was called 30 times, avg 159µs/call:
# 10 times (153µs+3.73ms) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 78 of Moose/Meta/Role/Application.pm, avg 388µs/call
# 10 times (66µs+616µs) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 77 of Moose/Meta/Role/Application.pm, avg 68µs/call
# 10 times (53µs+150µs) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 79 of Moose/Meta/Role/Application.pm, avg 20µs/call | ||||
224 | 30 | 9µs | my ($self, $modifier_type, $role, $class) = @_; | ||
225 | 30 | 9µs | my $add = "add_${modifier_type}_method_modifier"; | ||
226 | 30 | 6µs | my $get = "get_${modifier_type}_method_modifiers"; | ||
227 | 30 | 82µs | 30 | 145µs | foreach my $method_name ($role->get_method_modifier_list($modifier_type)) { # spent 145µs making 30 calls to Moose::Meta::Role::get_method_modifier_list, avg 5µs/call |
228 | $class->$add( | ||||
229 | $method_name, | ||||
230 | $_ | ||||
231 | 24 | 90µs | 48 | 4.35ms | ) foreach $role->$get($method_name); # spent 3.59ms making 21 calls to Class::MOP::Class::add_around_method_modifier, avg 171µs/call
# spent 559µs making 2 calls to Class::MOP::Class::add_before_method_modifier, avg 280µs/call
# spent 98µs making 1 call to Class::MOP::Class::add_after_method_modifier
# spent 87µs making 21 calls to Moose::Meta::Role::get_around_method_modifiers, avg 4µs/call
# spent 10µs making 2 calls to Moose::Meta::Role::get_before_method_modifiers, avg 5µs/call
# spent 5µs making 1 call to Moose::Meta::Role::get_after_method_modifiers |
232 | } | ||||
233 | } | ||||
234 | |||||
235 | 1 | 5µs | 1; | ||
236 | |||||
237 | # ABSTRACT: Compose a role into a class | ||||
238 | |||||
239 | __END__ |