← Index
NYTProf Performance Profile   « block view • line view • sub view »
For 05.Domain_and_Item.t
  Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:22:22 2010

File /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/Role/Application/ToClass.pm
Statements Executed 996
Statement Execution Time 3.33ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
13111.17ms28.0msMoose::Meta::Role::Application::ToClass::::apply_methodsMoose::Meta::Role::Application::ToClass::apply_methods
1311611µs61.5msMoose::Meta::Role::Application::ToClass::::apply_attributesMoose::Meta::Role::Application::ToClass::apply_attributes
3931547µs11.2msMoose::Meta::Role::Application::ToClass::::apply_method_modifiersMoose::Meta::Role::Application::ToClass::apply_method_modifiers
1311313µs106msMoose::Meta::Role::Application::ToClass::::applyMoose::Meta::Role::Application::ToClass::apply
1311174µs3.08msMoose::Meta::Role::Application::ToClass::::check_role_exclusionsMoose::Meta::Role::Application::ToClass::check_role_exclusions
1311143µs401µsMoose::Meta::Role::Application::ToClass::::check_required_methodsMoose::Meta::Role::Application::ToClass::check_required_methods
131196µs250µsMoose::Meta::Role::Application::ToClass::::apply_override_method_modifiersMoose::Meta::Role::Application::ToClass::apply_override_method_modifiers
131118µs18µsMoose::Meta::Role::Application::ToClass::::check_required_attributesMoose::Meta::Role::Application::ToClass::check_required_attributes
11115µs18µsMoose::Meta::Role::Application::ToClass::::BEGIN@3Moose::Meta::Role::Application::ToClass::BEGIN@3
1119µs210µsMoose::Meta::Role::Application::ToClass::::BEGIN@7Moose::Meta::Role::Application::ToClass::BEGIN@7
1119µs52µsMoose::Meta::Role::Application::ToClass::::BEGIN@14Moose::Meta::Role::Application::ToClass::BEGIN@14
1118µs37µsMoose::Meta::Role::Application::ToClass::::BEGIN@8Moose::Meta::Role::Application::ToClass::BEGIN@8
1118µs17µsMoose::Meta::Role::Application::ToClass::::BEGIN@4Moose::Meta::Role::Application::ToClass::BEGIN@4
1117µs112µsMoose::Meta::Role::Application::ToClass::::BEGIN@5Moose::Meta::Role::Application::ToClass::BEGIN@5
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moose::Meta::Role::Application::ToClass;
2
3321µs221µs
# spent 18µs (15+3) within Moose::Meta::Role::Application::ToClass::BEGIN@3 which was called # once (15µs+3µs) by Moose::BEGIN@30 at line 3
use strict;
# spent 18µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@3 # spent 3µs making 1 call to strict::import
4320µs226µs
# spent 17µs (8+9) within Moose::Meta::Role::Application::ToClass::BEGIN@4 which was called # once (8µs+9µs) by Moose::BEGIN@30 at line 4
use warnings;
# spent 17µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@4 # spent 9µs making 1 call to warnings::import
5327µs2216µs
# spent 112µs (7+105) within Moose::Meta::Role::Application::ToClass::BEGIN@5 which was called # once (7µs+105µs) by Moose::BEGIN@30 at line 5
use metaclass;
# spent 112µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@5 # spent 105µs making 1 call to metaclass::import
6
7331µs2411µs
# spent 210µs (9+201) within Moose::Meta::Role::Application::ToClass::BEGIN@7 which was called # once (9µs+201µs) by Moose::BEGIN@30 at line 7
use Moose::Util 'english_list';
# spent 210µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@7 # spent 201µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
8357µs266µs
# spent 37µs (8+29) within Moose::Meta::Role::Application::ToClass::BEGIN@8 which was called # once (8µs+29µs) by Moose::BEGIN@30 at line 8
use Scalar::Util 'weaken', 'blessed';
# spent 37µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@8 # spent 29µs making 1 call to Exporter::import
9
101700nsour $VERSION = '0.98';
11118µs$VERSION = eval $VERSION;
121300nsour $AUTHORITY = 'cpan:STEVAN';
13
143748µs295µs
# spent 52µs (9+43) within Moose::Meta::Role::Application::ToClass::BEGIN@14 which was called # once (9µs+43µs) by Moose::BEGIN@30 at line 14
use base 'Moose::Meta::Role::Application';
# spent 52µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@14 # spent 43µs making 1 call to base::import
15
1613µs2303µs__PACKAGE__->meta->add_attribute('role' => (
# spent 282µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 21µs making 1 call to Moose::Meta::Role::Application::ToClass::meta
17 reader => 'role',
18));
19
2013µs2293µs__PACKAGE__->meta->add_attribute('class' => (
# spent 280µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 13µs making 1 call to Moose::Meta::Role::Application::ToClass::meta
21 reader => 'class',
22));
23
24
# spent 106ms (313µs+106) within Moose::Meta::Role::Application::ToClass::apply which was called 13 times, avg 8.14ms/call: # 13 times (313µs+106ms) by Moose::Meta::Role::apply at line 419 of Moose/Meta/Role.pm, avg 8.14ms/call
sub apply {
2578314µs my ($self, $role, $class) = @_;
26
27 # We need weak_ref in CMOP :(
28 weaken($self->{role} = $role);
# spent 20µs making 13 calls to Scalar::Util::weaken, avg 2µs/call
29 weaken($self->{class} = $class);
# spent 15µs making 13 calls to Scalar::Util::weaken, avg 1µs/call
30
31 $self->SUPER::apply($role, $class);
# spent 105ms making 13 calls to Moose::Meta::Role::Application::apply, avg 8.09ms/call
32
33 $class->add_role($role);
# spent 185µs making 13 calls to Moose::Meta::Class::add_role, avg 14µs/call
34 $class->add_role_application($self);
# spent 190µs making 13 calls to Moose::Meta::Class::add_role_application, avg 15µs/call
35}
36
37
# spent 3.08ms (174µs+2.91) within Moose::Meta::Role::Application::ToClass::check_role_exclusions which was called 13 times, avg 237µs/call: # 13 times (174µs+2.91ms) by Moose::Meta::Role::Application::apply at line 68 of Moose/Meta/Role/Application.pm, avg 237µs/call
sub check_role_exclusions {
3839173µs my ($self, $role, $class) = @_;
39 if ($class->excludes_role($role->name)) {
# spent 2.75ms making 13 calls to Moose::Meta::Class::excludes_role, avg 212µs/call # spent 13µs making 13 calls to Class::MOP::Package::name, avg 1µs/call
40 $class->throw_error("Conflict detected: " . $class->name . " excludes role '" . $role->name . "'");
41 }
42 foreach my $excluded_role_name ($role->get_excluded_roles_list) {
# spent 145µs making 13 calls to Moose::Meta::Role::get_excluded_roles_list, avg 11µs/call
43 if ($class->does_role($excluded_role_name)) {
44 $class->throw_error("The class " . $class->name . " does the excluded role '$excluded_role_name'");
45 }
46 }
47}
48
49
# spent 401µs (143+258) within Moose::Meta::Role::Application::ToClass::check_required_methods which was called 13 times, avg 31µs/call: # 13 times (143µs+258µs) by Moose::Meta::Role::Application::apply at line 69 of Moose/Meta/Role/Application.pm, avg 31µs/call
sub check_required_methods {
5069121µs my ($self, $role, $class) = @_;
51
52 my @missing;
53 my @is_attr;
54
55 # NOTE:
56 # we might need to move this down below the
57 # the attributes so that we can require any
58 # attribute accessors. However I am thinking
59 # that maybe those are somehow exempt from
60 # the require methods stuff.
61 foreach my $required_method ($role->get_required_method_list) {
# spent 135µs making 13 calls to Moose::Meta::Role::get_required_method_list, avg 10µs/call
62 my $required_method_name = $required_method->name;
# spent 7µs making 2 calls to Moose::Meta::Role::Method::Required::name, avg 3µs/call
63
64 if (!$class->find_method_by_name($required_method_name)) {
# spent 116µs making 2 calls to Class::MOP::Class::find_method_by_name, avg 58µs/call
65
66 next if $self->is_aliased_method($required_method_name);
67
68 push @missing, $required_method;
69 }
70 }
71
72 return unless @missing;
73
74 my $error = '';
75
76 @missing = sort { $a->name cmp $b->name } @missing;
77 my @conflicts = grep { $_->isa('Moose::Meta::Role::Method::Conflicting') } @missing;
78
79 if (@conflicts) {
80 my $conflict = $conflicts[0];
81 my $roles = $conflict->roles_as_english_list;
82
83 my @same_role_conflicts = grep { $_->roles_as_english_list eq $roles } @conflicts;
84
85 if (@same_role_conflicts == 1) {
86 $error
87 .= "Due to a method name conflict in roles "
88 . $roles
89 . ", the method '"
90 . $conflict->name
91 . "' must be implemented or excluded by '"
92 . $class->name
93 . q{'};
94 }
95 else {
96 my $methods
97 = Moose::Util::english_list( map { q{'} . $_->name . q{'} } @same_role_conflicts );
98
99 $error
100 .= "Due to method name conflicts in roles "
101 . $roles
102 . ", the methods "
103 . $methods
104 . " must be implemented or excluded by '"
105 . $class->name
106 . q{'};
107 }
108 }
109 elsif (@missing) {
110 my $noun = @missing == 1 ? 'method' : 'methods';
111
112 my $list
113 = Moose::Util::english_list( map { q{'} . $_ . q{'} } @missing );
114
115 $error
116 .= q{'}
117 . $role->name
118 . "' requires the $noun $list "
119 . "to be implemented by '"
120 . $class->name . q{'};
121 }
122
123 $class->throw_error($error);
124}
125
1261330µs
# spent 18µs within Moose::Meta::Role::Application::ToClass::check_required_attributes which was called 13 times, avg 1µs/call: # 13 times (18µs+0s) by Moose::Meta::Role::Application::apply at line 70 of Moose/Meta/Role/Application.pm, avg 1µs/call
sub check_required_attributes {
127
128}
129
130
# spent 61.5ms (611µs+60.9) within Moose::Meta::Role::Application::ToClass::apply_attributes which was called 13 times, avg 4.73ms/call: # 13 times (611µs+60.9ms) by Moose::Meta::Role::Application::apply at line 72 of Moose/Meta/Role/Application.pm, avg 4.73ms/call
sub apply_attributes {
131113466µs my ($self, $role, $class) = @_;
132 my $attr_metaclass = $class->attribute_metaclass;
# spent 30µs making 13 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 2µs/call
133
134 foreach my $attribute_name ($role->get_attribute_list) {
# spent 111µs making 13 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 9µs/call
135 # it if it has one already
136 if ($class->has_attribute($attribute_name) &&
# spent 209µs making 37 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 6µs/call
137 # make sure we haven't seen this one already too
138 $class->get_attribute($attribute_name) != $role->get_attribute($attribute_name)) {
139 next;
140 }
141 else {
142 $class->add_attribute(
# spent 45.8ms making 37 calls to Moose::Meta::Class::add_attribute, avg 1.24ms/call # spent 14.6ms making 37 calls to Moose::Meta::Role::Attribute::attribute_for_class, avg 394µs/call # spent 187µs making 37 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 5µs/call
143 $role->get_attribute($attribute_name)->attribute_for_class($attr_metaclass)
144 );
145 }
146 }
147}
148
149
# spent 28.0ms (1.17+26.8) within Moose::Meta::Role::Application::ToClass::apply_methods which was called 13 times, avg 2.15ms/call: # 13 times (1.17ms+26.8ms) by Moose::Meta::Role::Application::apply at line 73 of Moose/Meta/Role/Application.pm, avg 2.15ms/call
sub apply_methods {
150392759µs my ($self, $role, $class) = @_;
151 foreach my $method_name ($role->get_method_list) {
# spent 9.34ms making 13 calls to Class::MOP::Mixin::HasMethods::get_method_list, avg 719µs/call
152 next if $method_name eq 'meta';
153
154 unless ($self->is_method_excluded($method_name)) {
# spent 476µs making 68 calls to Moose::Meta::Role::Application::is_method_excluded, avg 7µs/call
155 # it if it has one already
156 if ($class->has_method($method_name) &&
# spent 2.22ms making 68 calls to Class::MOP::Mixin::HasMethods::has_method, avg 33µs/call
157 # and if they are not the same thing ...
158 $class->get_method($method_name)->body != $role->get_method($method_name)->body) {
159 next;
160 }
161 else {
162 # add it, although it could be overridden
163 $class->add_method(
# spent 12.8ms making 68 calls to Class::MOP::Mixin::HasMethods::add_method, avg 188µs/call # spent 1.53ms making 68 calls to Class::MOP::Mixin::HasMethods::get_method, avg 22µs/call
164 $method_name,
165 $role->get_method($method_name)
166 );
167 }
168 }
169
170 if ($self->is_method_aliased($method_name)) {
# spent 420µs making 68 calls to Moose::Meta::Role::Application::is_method_aliased, avg 6µs/call
171 my $aliased_method_name = $self->get_method_aliases->{$method_name};
172 # it if it has one already
173 if ($class->has_method($aliased_method_name) &&
174 # and if they are not the same thing ...
175 $class->get_method($aliased_method_name)->body != $role->get_method($method_name)->body) {
176 $class->throw_error("Cannot create a method alias if a local method of the same name exists");
177 }
178 $class->add_method(
179 $aliased_method_name,
180 $role->get_method($method_name)
181 );
182 }
183 }
184 # we must reset the cache here since
185 # we are just aliasing methods, otherwise
186 # the modifiers go wonky.
187 $class->reset_package_cache_flag;
# spent 35µs making 13 calls to Class::MOP::Class::reset_package_cache_flag, avg 3µs/call
188}
189
190
# spent 250µs (96+154) within Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers which was called 13 times, avg 19µs/call: # 13 times (96µs+154µs) by Moose::Meta::Role::Application::apply at line 75 of Moose/Meta/Role/Application.pm, avg 19µs/call
sub apply_override_method_modifiers {
1912692µs my ($self, $role, $class) = @_;
192 foreach my $method_name ($role->get_method_modifier_list('override')) {
# spent 154µs making 13 calls to Moose::Meta::Role::get_method_modifier_list, avg 12µs/call
193 # it if it has one already then ...
194 if ($class->has_method($method_name)) {
195 next;
196 }
197 else {
198 # if this is not a role, then we need to
199 # find the original package of the method
200 # so that we can tell the class were to
201 # find the right super() method
202 my $method = $role->get_override_method_modifier($method_name);
203 my ($package) = Class::MOP::get_code_info($method);
204 # if it is a class, we just add it
205 $class->add_override_method_modifier($method_name, $method, $package);
206 }
207 }
208}
209
210
# spent 11.2ms (547µs+10.7) within Moose::Meta::Role::Application::ToClass::apply_method_modifiers which was called 39 times, avg 288µs/call: # 13 times (189µs+4.30ms) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 93 of Moose/Meta/Role/Application.pm, avg 345µs/call # 13 times (146µs+3.23ms) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 92 of Moose/Meta/Role/Application.pm, avg 260µs/call # 13 times (212µs+3.16ms) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 91 of Moose/Meta/Role/Application.pm, avg 260µs/call
sub apply_method_modifiers {
211242433µs my ($self, $modifier_type, $role, $class) = @_;
212 my $add = "add_${modifier_type}_method_modifier";
213 my $get = "get_${modifier_type}_method_modifiers";
214 foreach my $method_name ($role->get_method_modifier_list($modifier_type)) {
# spent 341µs making 39 calls to Moose::Meta::Role::get_method_modifier_list, avg 9µs/call
215 $class->$add(
216 $method_name,
217 $_
218 ) foreach $role->$get($method_name);
# spent 4.06ms making 20 calls to Class::MOP::Class::add_after_method_modifier, avg 203µs/call # spent 3.04ms making 10 calls to Class::MOP::Class::add_around_method_modifier, avg 304µs/call # spent 2.95ms making 13 calls to Class::MOP::Class::add_before_method_modifier, avg 227µs/call # spent 128µs making 20 calls to Moose::Meta::Role::get_after_method_modifiers, avg 6µs/call # spent 100µs making 13 calls to Moose::Meta::Role::get_before_method_modifiers, avg 8µs/call # spent 75µs making 10 calls to Moose::Meta::Role::get_around_method_modifiers, avg 8µs/call
219 }
220}
221
22219µs1;
223
224__END__
225
226=pod
227
228=head1 NAME
229
230Moose::Meta::Role::Application::ToClass - Compose a role into a class
231
232=head1 DESCRIPTION
233
234=head2 METHODS
235
236=over 4
237
238=item B<new>
239
240=item B<meta>
241
242=item B<apply>
243
244=item B<check_role_exclusions>
245
246=item B<check_required_methods>
247
248=item B<check_required_attributes>
249
250=item B<apply_attributes>
251
252=item B<apply_methods>
253
254=item B<apply_method_modifiers>
255
256=item B<apply_override_method_modifiers>
257
258=back
259
260=head1 BUGS
261
262See L<Moose/BUGS> for details on reporting bugs.
263
264=head1 AUTHOR
265
266Stevan Little E<lt>stevan@iinteractive.comE<gt>
267
268=head1 COPYRIGHT AND LICENSE
269
270Copyright 2006-2010 by Infinity Interactive, Inc.
271
272L<http://www.iinteractive.com>
273
274This library is free software; you can redistribute it and/or modify
275it under the same terms as Perl itself.
276
277=cut
278