← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:10:08 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Role/Application/ToClass.pm
StatementsExecuted 7702 statements in 116ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
731168.9ms861msMoose::Meta::Role::Application::ToClass::::apply_methodsMoose::Meta::Role::Application::ToClass::apply_methods
2193111.0ms166msMoose::Meta::Role::Application::ToClass::::apply_method_modifiersMoose::Meta::Role::Application::ToClass::apply_method_modifiers
73116.94ms1.58sMoose::Meta::Role::Application::ToClass::::applyMoose::Meta::Role::Application::ToClass::apply
73115.79ms95.5msMoose::Meta::Role::Application::ToClass::::apply_override_method_modifiersMoose::Meta::Role::Application::ToClass::apply_override_method_modifiers
73115.18ms274msMoose::Meta::Role::Application::ToClass::::apply_attributesMoose::Meta::Role::Application::ToClass::apply_attributes
73114.39ms136msMoose::Meta::Role::Application::ToClass::::check_role_exclusionsMoose::Meta::Role::Application::ToClass::check_role_exclusions
73113.17ms14.1msMoose::Meta::Role::Application::ToClass::::check_required_methodsMoose::Meta::Role::Application::ToClass::check_required_methods
7311549µs549µsMoose::Meta::Role::Application::ToClass::::check_required_attributesMoose::Meta::Role::Application::ToClass::check_required_attributes
11197µs122µsMoose::Meta::Role::Application::ToClass::::BEGIN@3Moose::Meta::Role::Application::ToClass::BEGIN@3
11146µs298µsMoose::Meta::Role::Application::ToClass::::BEGIN@14Moose::Meta::Role::Application::ToClass::BEGIN@14
11142µs899µsMoose::Meta::Role::Application::ToClass::::BEGIN@7Moose::Meta::Role::Application::ToClass::BEGIN@7
11142µs231µsMoose::Meta::Role::Application::ToClass::::BEGIN@8Moose::Meta::Role::Application::ToClass::BEGIN@8
11141µs111µsMoose::Meta::Role::Application::ToClass::::BEGIN@4Moose::Meta::Role::Application::ToClass::BEGIN@4
11137µs3.04msMoose::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
33122µs2147µs
# spent 122µs (97+25) within Moose::Meta::Role::Application::ToClass::BEGIN@3 which was called: # once (97µs+25µs) by Moose::BEGIN@31 at line 3
use strict;
# spent 122µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@3 # spent 25µs making 1 call to strict::import
4397µs2181µs
# spent 111µs (41+70) within Moose::Meta::Role::Application::ToClass::BEGIN@4 which was called: # once (41µs+70µs) by Moose::BEGIN@31 at line 4
use warnings;
# spent 111µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@4 # spent 70µs making 1 call to warnings::import
53155µs26.04ms
# spent 3.04ms (37µs+3.00) within Moose::Meta::Role::Application::ToClass::BEGIN@5 which was called: # once (37µs+3.00ms) by Moose::BEGIN@31 at line 5
use metaclass;
# spent 3.04ms making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@5 # spent 3.00ms making 1 call to metaclass::import
6
73149µs21.76ms
# spent 899µs (42+857) within Moose::Meta::Role::Application::ToClass::BEGIN@7 which was called: # once (42µs+857µs) by Moose::BEGIN@31 at line 7
use Moose::Util 'english_list';
# spent 899µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@7 # spent 857µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
83246µs2420µs
# spent 231µs (42+189) within Moose::Meta::Role::Application::ToClass::BEGIN@8 which was called: # once (42µs+189µs) by Moose::BEGIN@31 at line 8
use Scalar::Util 'weaken', 'blessed';
# spent 231µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@8 # spent 189µs making 1 call to Exporter::import
9
1016µsour $VERSION = '1.19';
11169µs$VERSION = eval $VERSION;
# spent 11µs executing statements in string eval
1213µsour $AUTHORITY = 'cpan:STEVAN';
13
1433.18ms2550µs
# spent 298µs (46+252) within Moose::Meta::Role::Application::ToClass::BEGIN@14 which was called: # once (46µs+252µs) by Moose::BEGIN@31 at line 14
use base 'Moose::Meta::Role::Application';
# spent 298µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@14 # spent 252µs making 1 call to base::import
15
16132µs22.23ms__PACKAGE__->meta->add_attribute('role' => (
# spent 2.09ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 145µs making 1 call to Moose::Meta::Role::Application::ToClass::meta
17 reader => 'role',
18));
19
20124µs22.09ms__PACKAGE__->meta->add_attribute('class' => (
# spent 2.01ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 84µs making 1 call to Moose::Meta::Role::Application::ToClass::meta
21 reader => 'class',
22));
23
24
# spent 1.58s (6.94ms+1.57) within Moose::Meta::Role::Application::ToClass::apply which was called 73 times, avg 21.6ms/call: # 73 times (6.94ms+1.57s) by Moose::Meta::Role::apply at line 483 of Moose/Meta/Role.pm, avg 21.6ms/call
sub apply {
254387.69ms my ($self, $role, $class) = @_;
26
27 # We need weak_ref in CMOP :(
2873512µs weaken($self->{role} = $role);
# spent 512µs making 73 calls to Scalar::Util::weaken, avg 7µs/call
2973416µs weaken($self->{class} = $class);
# spent 416µs making 73 calls to Scalar::Util::weaken, avg 6µs/call
30
31731.56s $self->SUPER::apply($role, $class);
# spent 1.56s making 73 calls to Moose::Meta::Role::Application::apply, avg 21.4ms/call
32
33735.66ms $class->add_role($role);
# spent 5.66ms making 73 calls to Moose::Meta::Class::add_role, avg 77µs/call
34735.41ms $class->add_role_application($self);
# spent 5.41ms making 73 calls to Moose::Meta::Class::add_role_application, avg 74µs/call
35}
36
37
# spent 136ms (4.39+132) within Moose::Meta::Role::Application::ToClass::check_role_exclusions which was called 73 times, avg 1.86ms/call: # 73 times (4.39ms+132ms) by Moose::Meta::Role::Application::apply at line 50 of Moose/Meta/Role/Application.pm, avg 1.86ms/call
sub check_role_exclusions {
382194.77ms my ($self, $role, $class) = @_;
39146128ms if ($class->excludes_role($role->name)) {
# spent 128ms making 73 calls to Moose::Meta::Class::excludes_role, avg 1.75ms/call # spent 484µs making 73 calls to Class::MOP::Package::name, avg 7µs/call
40 $class->throw_error("Conflict detected: " . $class->name . " excludes role '" . $role->name . "'");
41 }
42733.15ms foreach my $excluded_role_name ($role->get_excluded_roles_list) {
# spent 3.15ms making 73 calls to Moose::Meta::Role::get_excluded_roles_list, avg 43µ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 14.1ms (3.17+10.9) within Moose::Meta::Role::Application::ToClass::check_required_methods which was called 73 times, avg 193µs/call: # 73 times (3.17ms+10.9ms) by Moose::Meta::Role::Application::apply at line 51 of Moose/Meta/Role/Application.pm, avg 193µs/call
sub check_required_methods {
503853.10ms 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.
61732.93ms foreach my $required_method ($role->get_required_method_list) {
# spent 2.93ms making 73 calls to Moose::Meta::Role::get_required_method_list, avg 40µs/call
6210154µs my $required_method_name = $required_method->name;
# spent 154µs making 10 calls to Moose::Meta::Role::Method::Required::name, avg 15µs/call
63
64107.82ms if (!$class->find_method_by_name($required_method_name)) {
# spent 7.82ms making 10 calls to Class::MOP::Class::find_method_by_name, avg 782µ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
12673735µs
# spent 549µs within Moose::Meta::Role::Application::ToClass::check_required_attributes which was called 73 times, avg 8µs/call: # 73 times (549µs+0s) by Moose::Meta::Role::Application::apply at line 52 of Moose/Meta/Role/Application.pm, avg 8µs/call
sub check_required_attributes {
127
128}
129
130
# spent 274ms (5.18+269) within Moose::Meta::Role::Application::ToClass::apply_attributes which was called 73 times, avg 3.75ms/call: # 73 times (5.18ms+269ms) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 3.75ms/call
sub apply_attributes {
1312614.75ms my ($self, $role, $class) = @_;
13273899µs my $attr_metaclass = $class->attribute_metaclass;
# spent 899µs making 73 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 12µs/call
133
134732.81ms foreach my $attribute_name ($role->get_attribute_list) {
# spent 2.81ms making 73 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 39µs/call
135 # it if it has one already
13621992µs if ($class->has_attribute($attribute_name) &&
# spent 992µs making 21 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 47µ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 {
14263184ms $class->add_attribute(
# spent 95.7ms making 21 calls to Moose::Meta::Role::Attribute::attribute_for_class, avg 4.56ms/call # spent 168ms making 21 calls to Moose::Meta::Class::add_attribute, avg 7.98ms/call, recursion: max depth 1, sum of overlapping time 79.9ms # spent 804µs making 21 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 38µs/call
143 $role->get_attribute($attribute_name)->attribute_for_class($attr_metaclass)
144 );
145 }
146 }
147}
148
149
# spent 861ms (68.9+792) within Moose::Meta::Role::Application::ToClass::apply_methods which was called 73 times, avg 11.8ms/call: # 73 times (68.9ms+792ms) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 11.8ms/call
sub apply_methods {
150496474.4ms my ( $self, $role, $class ) = @_;
151
15273206ms foreach my $method ( $role->_get_local_methods ) {
# spent 206ms making 73 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 2.82ms/call
1537304.50ms my $method_name = $method->name;
# spent 4.50ms making 730 calls to Class::MOP::Method::name, avg 6µs/call
154
1557307.45ms next if $method->isa('Class::MOP::Method::Meta');
# spent 7.45ms making 730 calls to UNIVERSAL::isa, avg 10µs/call
156
15765729.4ms unless ( $self->is_method_excluded($method_name) ) {
# spent 29.4ms making 657 calls to Moose::Meta::Role::Application::is_method_excluded, avg 45µs/call
158
159657186ms my $class_method = $class->get_method($method_name);
# spent 186ms making 657 calls to Class::MOP::Mixin::HasMethods::get_method, avg 284µs/call
160
161 next if $class_method && $class_method->body != $method->body;
162
163657330ms $class->add_method(
# spent 330ms making 657 calls to Class::MOP::Mixin::HasMethods::add_method, avg 502µs/call
164 $method_name,
165 $method,
166 );
167 }
168
16965727.2ms next unless $self->is_method_aliased($method_name);
# spent 27.2ms making 657 calls to Moose::Meta::Role::Application::is_method_aliased, avg 41µs/call
170
171 my $aliased_method_name = $self->get_method_aliases->{$method_name};
172
173 my $class_method = $class->get_method($aliased_method_name);
174
175 if ( $class_method && $class_method->body != $method->body ) {
176 $class->throw_error(
177 "Cannot create a method alias if a local method of the same name exists"
178 );
179 }
180
181 $class->add_method(
182 $aliased_method_name,
183 $method,
184 );
185 }
186
187 # we must reset the cache here since
188 # we are just aliasing methods, otherwise
189 # the modifiers go wonky.
19073892µs $class->reset_package_cache_flag;
# spent 892µs making 73 calls to Class::MOP::Class::reset_package_cache_flag, avg 12µs/call
191}
192
193
# spent 95.5ms (5.79+89.7) within Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers which was called 73 times, avg 1.31ms/call: # 73 times (5.79ms+89.7ms) by Moose::Meta::Role::Application::apply at line 57 of Moose/Meta/Role/Application.pm, avg 1.31ms/call
sub apply_override_method_modifiers {
1943265.80ms my ($self, $role, $class) = @_;
195733.50ms foreach my $method_name ($role->get_method_modifier_list('override')) {
# spent 3.50ms making 73 calls to Moose::Meta::Role::get_method_modifier_list, avg 48µs/call
196 # it if it has one already then ...
1974513.6ms if ($class->has_method($method_name)) {
# spent 13.6ms making 45 calls to Class::MOP::Mixin::HasMethods::has_method, avg 303µs/call
198 next;
199 }
200 else {
201 # if this is not a role, then we need to
202 # find the original package of the method
203 # so that we can tell the class were to
204 # find the right super() method
205451.92ms my $method = $role->get_override_method_modifier($method_name);
# spent 1.92ms making 45 calls to Moose::Meta::Role::get_override_method_modifier, avg 43µs/call
20645491µs my ($package) = Class::MOP::get_code_info($method);
# spent 491µs making 45 calls to Class::MOP::get_code_info, avg 11µs/call
207 # if it is a class, we just add it
2084570.1ms $class->add_override_method_modifier($method_name, $method, $package);
# spent 70.1ms making 45 calls to Moose::Meta::Class::add_override_method_modifier, avg 1.56ms/call
209 }
210 }
211}
212
213
# spent 166ms (11.0+155) within Moose::Meta::Role::Application::ToClass::apply_method_modifiers which was called 219 times, avg 757µs/call: # 73 times (4.90ms+119ms) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 74 of Moose/Meta/Role/Application.pm, avg 1.69ms/call # 73 times (3.20ms+26.0ms) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 73 of Moose/Meta/Role/Application.pm, avg 400µs/call # 73 times (2.89ms+10.3ms) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 75 of Moose/Meta/Role/Application.pm, avg 180µs/call
sub apply_method_modifiers {
214101210.7ms my ($self, $modifier_type, $role, $class) = @_;
215 my $add = "add_${modifier_type}_method_modifier";
216 my $get = "get_${modifier_type}_method_modifiers";
2172199.28ms foreach my $method_name ($role->get_method_modifier_list($modifier_type)) {
# spent 9.28ms making 219 calls to Moose::Meta::Role::get_method_modifier_list, avg 42µs/call
218 $class->$add(
219 $method_name,
220 $_
221137146ms ) foreach $role->$get($method_name);
# spent 113ms making 52 calls to Class::MOP::Class::add_around_method_modifier, avg 2.18ms/call # spent 22.4ms making 11 calls to Class::MOP::Class::add_before_method_modifier, avg 2.04ms/call # spent 6.72ms making 6 calls to Class::MOP::Class::add_after_method_modifier, avg 1.12ms/call # spent 2.45ms making 51 calls to Moose::Meta::Role::get_around_method_modifiers, avg 48µs/call # spent 489µs making 11 calls to Moose::Meta::Role::get_before_method_modifiers, avg 44µs/call # spent 322µs making 6 calls to Moose::Meta::Role::get_after_method_modifiers, avg 54µs/call
222 }
223}
224
225132µs1;
226
227__END__