← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 22:00:36 2010
Reported on Wed Nov 17 22:13:38 2010

Filename/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Role/Application/ToClass.pm
StatementsExecuted 7765 statements in 110ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
731166.7ms642msMoose::Meta::Role::Application::ToClass::::apply_methodsMoose::Meta::Role::Application::ToClass::apply_methods
2193110.4ms135msMoose::Meta::Role::Application::ToClass::::apply_method_modifiersMoose::Meta::Role::Application::ToClass::apply_method_modifiers
73116.97ms1.21sMoose::Meta::Role::Application::ToClass::::applyMoose::Meta::Role::Application::ToClass::apply
73115.10ms198msMoose::Meta::Role::Application::ToClass::::apply_attributesMoose::Meta::Role::Application::ToClass::apply_attributes
73114.69ms66.3msMoose::Meta::Role::Application::ToClass::::apply_override_method_modifiersMoose::Meta::Role::Application::ToClass::apply_override_method_modifiers
73114.25ms121msMoose::Meta::Role::Application::ToClass::::check_role_exclusionsMoose::Meta::Role::Application::ToClass::check_role_exclusions
73113.24ms13.1msMoose::Meta::Role::Application::ToClass::::check_required_methodsMoose::Meta::Role::Application::ToClass::check_required_methods
7311535µs535µsMoose::Meta::Role::Application::ToClass::::check_required_attributesMoose::Meta::Role::Application::ToClass::check_required_attributes
11170µs88µsMoose::Meta::Role::Application::ToClass::::BEGIN@3Moose::Meta::Role::Application::ToClass::BEGIN@3
11143µs331µsMoose::Meta::Role::Application::ToClass::::BEGIN@14Moose::Meta::Role::Application::ToClass::BEGIN@14
11142µs916µsMoose::Meta::Role::Application::ToClass::::BEGIN@7Moose::Meta::Role::Application::ToClass::BEGIN@7
11142µs234µsMoose::Meta::Role::Application::ToClass::::BEGIN@8Moose::Meta::Role::Application::ToClass::BEGIN@8
11140µs2.74msMoose::Meta::Role::Application::ToClass::::BEGIN@5Moose::Meta::Role::Application::ToClass::BEGIN@5
11140µs107µsMoose::Meta::Role::Application::ToClass::::BEGIN@4Moose::Meta::Role::Application::ToClass::BEGIN@4
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
33102µs2106µs
# spent 88µs (70+18) within Moose::Meta::Role::Application::ToClass::BEGIN@3 which was called: # once (70µs+18µs) by Moose::BEGIN@31 at line 3
use strict;
# spent 88µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@3 # spent 18µs making 1 call to strict::import
4396µs2174µs
# spent 107µs (40+67) within Moose::Meta::Role::Application::ToClass::BEGIN@4 which was called: # once (40µs+67µs) by Moose::BEGIN@31 at line 4
use warnings;
# spent 107µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@4 # spent 67µs making 1 call to warnings::import
53144µs25.43ms
# spent 2.74ms (40µs+2.70) within Moose::Meta::Role::Application::ToClass::BEGIN@5 which was called: # once (40µs+2.70ms) by Moose::BEGIN@31 at line 5
use metaclass;
# spent 2.74ms making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@5 # spent 2.70ms making 1 call to metaclass::import
6
73166µs21.79ms
# spent 916µs (42+874) within Moose::Meta::Role::Application::ToClass::BEGIN@7 which was called: # once (42µs+874µs) by Moose::BEGIN@31 at line 7
use Moose::Util 'english_list';
# spent 916µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@7 # spent 874µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
83259µs2426µs
# spent 234µs (42+192) within Moose::Meta::Role::Application::ToClass::BEGIN@8 which was called: # once (42µs+192µs) by Moose::BEGIN@31 at line 8
use Scalar::Util 'weaken', 'blessed';
# spent 234µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@8 # spent 192µs making 1 call to Exporter::import
9
1015µsour $VERSION = '1.19';
11161µs$VERSION = eval $VERSION;
# spent 12µs executing statements in string eval
1214µsour $AUTHORITY = 'cpan:STEVAN';
13
1433.06ms2620µs
# spent 331µs (43+288) within Moose::Meta::Role::Application::ToClass::BEGIN@14 which was called: # once (43µs+288µs) by Moose::BEGIN@31 at line 14
use base 'Moose::Meta::Role::Application';
# spent 331µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@14 # spent 288µs making 1 call to base::import
15
16128µs22.15ms__PACKAGE__->meta->add_attribute('role' => (
# spent 2.03ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 120µs making 1 call to Moose::Meta::Role::Application::ToClass::meta
17 reader => 'role',
18));
19
20123µs21.99ms__PACKAGE__->meta->add_attribute('class' => (
# spent 1.90ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 89µs making 1 call to Moose::Meta::Role::Application::ToClass::meta
21 reader => 'class',
22));
23
24
# spent 1.21s (6.97ms+1.20) within Moose::Meta::Role::Application::ToClass::apply which was called 73 times, avg 16.6ms/call: # 73 times (6.97ms+1.20s) by Moose::Meta::Role::apply at line 483 of Moose/Meta/Role.pm, avg 16.6ms/call
sub apply {
2573282µs my ($self, $role, $class) = @_;
26
27 # We need weak_ref in CMOP :(
28731.45ms73487µs weaken($self->{role} = $role);
# spent 487µs making 73 calls to Scalar::Util::weaken, avg 7µs/call
29731.42ms73407µs weaken($self->{class} = $class);
# spent 407µs making 73 calls to Scalar::Util::weaken, avg 6µs/call
30
31732.08ms731.19s $self->SUPER::apply($role, $class);
# spent 1.19s making 73 calls to Moose::Meta::Role::Application::apply, avg 16.3ms/call
32
3373983µs736.22ms $class->add_role($role);
# spent 6.22ms making 73 calls to Moose::Meta::Class::add_role, avg 85µs/call
34731.56ms735.31ms $class->add_role_application($self);
# spent 5.31ms making 73 calls to Moose::Meta::Class::add_role_application, avg 73µs/call
35}
36
37
# spent 121ms (4.25+116) within Moose::Meta::Role::Application::ToClass::check_role_exclusions which was called 73 times, avg 1.65ms/call: # 73 times (4.25ms+116ms) by Moose::Meta::Role::Application::apply at line 50 of Moose/Meta/Role/Application.pm, avg 1.65ms/call
sub check_role_exclusions {
3873281µs my ($self, $role, $class) = @_;
39732.28ms146113ms if ($class->excludes_role($role->name)) {
# spent 113ms making 73 calls to Moose::Meta::Class::excludes_role, avg 1.55ms/call # spent 455µs making 73 calls to Class::MOP::Package::name, avg 6µs/call
40 $class->throw_error("Conflict detected: " . $class->name . " excludes role '" . $role->name . "'");
41 }
42732.04ms733.04ms foreach my $excluded_role_name ($role->get_excluded_roles_list) {
# spent 3.04ms making 73 calls to Moose::Meta::Role::get_excluded_roles_list, avg 42µ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 13.1ms (3.24+9.90) within Moose::Meta::Role::Application::ToClass::check_required_methods which was called 73 times, avg 180µs/call: # 73 times (3.24ms+9.90ms) by Moose::Meta::Role::Application::apply at line 51 of Moose/Meta/Role/Application.pm, avg 180µs/call
sub check_required_methods {
5073253µs my ($self, $role, $class) = @_;
51
5273140µs my @missing;
5373121µs 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.
61731.18ms732.90ms foreach my $required_method ($role->get_required_method_list) {
# spent 2.90ms making 73 calls to Moose::Meta::Role::get_required_method_list, avg 40µs/call
6213187µs13208µs my $required_method_name = $required_method->name;
# spent 208µs making 13 calls to Moose::Meta::Role::Method::Required::name, avg 16µs/call
63
6413265µs136.78ms if (!$class->find_method_by_name($required_method_name)) {
# spent 6.78ms making 13 calls to Class::MOP::Class::find_method_by_name, avg 522µs/call
65
66 next if $self->is_aliased_method($required_method_name);
67
68 push @missing, $required_method;
69 }
70 }
71
7273878µs 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
12673717µs
# spent 535µs within Moose::Meta::Role::Application::ToClass::check_required_attributes which was called 73 times, avg 7µs/call: # 73 times (535µs+0s) by Moose::Meta::Role::Application::apply at line 52 of Moose/Meta/Role/Application.pm, avg 7µs/call
sub check_required_attributes {
127
128}
129
130
# spent 198ms (5.10+193) within Moose::Meta::Role::Application::ToClass::apply_attributes which was called 73 times, avg 2.71ms/call: # 73 times (5.10ms+193ms) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 2.71ms/call
sub apply_attributes {
13173250µs my ($self, $role, $class) = @_;
13273908µs731.03ms my $attr_metaclass = $role->applied_attribute_metaclass;
# spent 1.03ms making 73 calls to Moose::Meta::Role::applied_attribute_metaclass, avg 14µs/call
133
134731.97ms732.46ms foreach my $attribute_name ($role->get_attribute_list) {
# spent 2.46ms making 73 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 34µs/call
135 # it if it has one already
13621725µs21741µs if ($class->has_attribute($attribute_name) &&
# spent 741µs making 21 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 35µ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 {
14221769µs63114ms $class->add_attribute(
# spent 144ms making 21 calls to Moose::Meta::Class::add_attribute, avg 6.85ms/call, recursion: max depth 1, sum of overlapping time 74.8ms # spent 43.8ms making 21 calls to Moose::Meta::Role::Attribute::attribute_for_class, avg 2.09ms/call # spent 694µs making 21 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 33µs/call
143 $role->get_attribute($attribute_name)->attribute_for_class($attr_metaclass)
144 );
145 }
146 }
147}
148
149
# spent 642ms (66.7+575) within Moose::Meta::Role::Application::ToClass::apply_methods which was called 73 times, avg 8.79ms/call: # 73 times (66.7ms+575ms) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 8.79ms/call
sub apply_methods {
15073256µs my ( $self, $role, $class ) = @_;
151
152733.24ms73103ms foreach my $method ( $role->_get_local_methods ) {
# spent 103ms making 73 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 1.41ms/call
15374514.5ms7454.27ms my $method_name = $method->name;
# spent 4.27ms making 745 calls to Class::MOP::Method::name, avg 6µs/call
154
15574516.5ms7457.71ms next if $method->isa('Class::MOP::Method::Meta');
# spent 7.71ms making 745 calls to UNIVERSAL::isa, avg 10µs/call
156
1576728.88ms67229.9ms unless ( $self->is_method_excluded($method_name) ) {
# spent 29.9ms making 672 calls to Moose::Meta::Role::Application::is_method_excluded, avg 45µs/call
158
1596727.54ms67299.3ms my $class_method = $class->get_method($method_name);
# spent 99.3ms making 672 calls to Class::MOP::Mixin::HasMethods::get_method, avg 148µs/call
160
1616721.26ms next if $class_method && $class_method->body != $method->body;
162
1636728.05ms672302ms $class->add_method(
# spent 302ms making 672 calls to Class::MOP::Mixin::HasMethods::add_method, avg 450µs/call
164 $method_name,
165 $method,
166 );
167 }
168
1696729.15ms67227.3ms next unless $self->is_method_aliased($method_name);
# spent 27.3ms making 672 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.
190731.55ms73778µs $class->reset_package_cache_flag;
# spent 778µs making 73 calls to Class::MOP::Mixin::HasMethods::reset_package_cache_flag, avg 11µs/call
191}
192
193
# spent 66.3ms (4.69+61.6) within Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers which was called 73 times, avg 908µs/call: # 73 times (4.69ms+61.6ms) by Moose::Meta::Role::Application::apply at line 57 of Moose/Meta/Role/Application.pm, avg 908µs/call
sub apply_override_method_modifiers {
19473265µs my ($self, $role, $class) = @_;
195731.87ms733.46ms foreach my $method_name ($role->get_method_modifier_list('override')) {
# spent 3.46ms making 73 calls to Moose::Meta::Role::get_method_modifier_list, avg 47µs/call
196 # it if it has one already then ...
19736675µs3610.3ms if ($class->has_method($method_name)) {
# spent 10.3ms making 36 calls to Class::MOP::Mixin::HasMethods::has_method, avg 286µ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
20536483µs361.49ms my $method = $role->get_override_method_modifier($method_name);
# spent 1.49ms making 36 calls to Moose::Meta::Role::get_override_method_modifier, avg 41µs/call
20636819µs36334µs my ($package) = Class::MOP::get_code_info($method);
# spent 334µs making 36 calls to Class::MOP::get_code_info, avg 9µs/call
207 # if it is a class, we just add it
20836476µs3646.0ms $class->add_override_method_modifier($method_name, $method, $package);
# spent 46.0ms making 36 calls to Moose::Meta::Class::add_override_method_modifier, avg 1.28ms/call
209 }
210 }
211}
212
213
# spent 135ms (10.4+125) within Moose::Meta::Role::Application::ToClass::apply_method_modifiers which was called 219 times, avg 617µs/call: # 73 times (4.66ms+92.9ms) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 74 of Moose/Meta/Role/Application.pm, avg 1.34ms/call # 73 times (3.04ms+23.1ms) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 73 of Moose/Meta/Role/Application.pm, avg 358µs/call # 73 times (2.74ms+8.73ms) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 75 of Moose/Meta/Role/Application.pm, avg 157µs/call
sub apply_method_modifiers {
214219847µs my ($self, $modifier_type, $role, $class) = @_;
215219866µs my $add = "add_${modifier_type}_method_modifier";
216219580µs my $get = "get_${modifier_type}_method_modifiers";
2172195.13ms2199.61ms foreach my $method_name ($role->get_method_modifier_list($modifier_type)) {
# spent 9.61ms making 219 calls to Moose::Meta::Role::get_method_modifier_list, avg 44µs/call
218 $class->$add(
219 $method_name,
220 $_
2211242.61ms124115ms ) foreach $role->$get($method_name);
# spent 87.5ms making 45 calls to Class::MOP::Class::add_around_method_modifier, avg 1.94ms/call # spent 19.2ms making 11 calls to Class::MOP::Class::add_before_method_modifier, avg 1.75ms/call # spent 5.35ms making 6 calls to Class::MOP::Class::add_after_method_modifier, avg 892µs/call # spent 2.24ms making 45 calls to Moose::Meta::Role::get_around_method_modifiers, avg 50µs/call # spent 509µs making 11 calls to Moose::Meta::Role::get_before_method_modifiers, avg 46µs/call # spent 266µs making 6 calls to Moose::Meta::Role::get_after_method_modifiers, avg 44µs/call
222 }
223}
224
225130µs1;
226
227__END__