← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:11 2016

Filename/usr/local/lib/perl/5.18.2/Moose/Meta/Role/Application/ToClass.pm
StatementsExecuted 3309 statements in 10.1ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
28117.17ms47.5msMoose::Meta::Role::Application::ToClass::::apply_methodsMoose::Meta::Role::Application::ToClass::apply_methods
28115.38ms13.4msMoose::Meta::Role::Application::ToClass::::apply_override_method_modifiersMoose::Meta::Role::Application::ToClass::apply_override_method_modifiers
2811870µs268msMoose::Meta::Role::Application::ToClass::::apply_attributesMoose::Meta::Role::Application::ToClass::apply_attributes (recurses: max depth 1, inclusive time 2.62ms)
8431487µs5.70msMoose::Meta::Role::Application::ToClass::::apply_method_modifiersMoose::Meta::Role::Application::ToClass::apply_method_modifiers
2811406µs335msMoose::Meta::Role::Application::ToClass::::applyMoose::Meta::Role::Application::ToClass::apply (recurses: max depth 1, inclusive time 14.2ms)
2811344µs2.89msMoose::Meta::Role::Application::ToClass::::check_required_methodsMoose::Meta::Role::Application::ToClass::check_required_methods
2811283µs5.28msMoose::Meta::Role::Application::ToClass::::check_role_exclusionsMoose::Meta::Role::Application::ToClass::check_role_exclusions
281125µs25µsMoose::Meta::Role::Application::ToClass::::check_required_attributesMoose::Meta::Role::Application::ToClass::check_required_attributes
11111µs42µsMoose::Meta::Role::Application::ToClass::::BEGIN@8Moose::Meta::Role::Application::ToClass::BEGIN@8
11110µs23µsMoose::Meta::Role::Application::ToClass::::BEGIN@4Moose::Meta::Role::Application::ToClass::BEGIN@4
1118µs14µsMoose::Meta::Role::Application::ToClass::::BEGIN@5Moose::Meta::Role::Application::ToClass::BEGIN@5
1117µs28µsMoose::Meta::Role::Application::ToClass::::BEGIN@12Moose::Meta::Role::Application::ToClass::BEGIN@12
1116µs27µsMoose::Meta::Role::Application::ToClass::::BEGIN@10Moose::Meta::Role::Application::ToClass::BEGIN@10
1116µs150µsMoose::Meta::Role::Application::ToClass::::BEGIN@9Moose::Meta::Role::Application::ToClass::BEGIN@9
1116µs399µsMoose::Meta::Role::Application::ToClass::::BEGIN@6Moose::Meta::Role::Application::ToClass::BEGIN@6
0000s0sMoose::Meta::Role::Application::ToClass::::__ANON__[:95]Moose::Meta::Role::Application::ToClass::__ANON__[:95]
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;
21400nsour $VERSION = '2.1604';
3
4221µs236µ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
use strict;
# spent 23µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@4 # spent 13µs making 1 call to strict::import
5220µs219µ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
use warnings;
# spent 14µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@5 # spent 6µs making 1 call to warnings::import
6229µs2792µ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
use metaclass;
# spent 399µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@6 # spent 393µs making 1 call to metaclass::import
7
8223µs250µ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
use List::Util 'first';
# spent 42µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@8 # spent 8µs making 1 call to List::Util::import
9225µs2293µ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
use Moose::Util 'throw_exception';
# 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]
10223µs247µ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
use Scalar::Util 'weaken';
# spent 27µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@10 # spent 20µs making 1 call to Exporter::import
11
122712µs249µ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
use parent 'Moose::Meta::Role::Application';
# spent 28µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@12 # spent 21µs making 1 call to parent::import
13
1416µs3366µ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
1913µs3252µ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
sub apply {
252812µs my ($self, $role, $class) = @_;
26
27 # We need weak_ref in CMOP :(
282891µs2826µs weaken($self->{role} = $role);
# spent 26µs making 28 calls to Scalar::Util::weaken, avg 929ns/call
292867µs2815µs weaken($self->{class} = $class);
# spent 15µs making 28 calls to Scalar::Util::weaken, avg 529ns/call
30
312860µs28333ms $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
332868µs28360µs $class->add_role($role);
# spent 360µs making 28 calls to Moose::Meta::Class::add_role, avg 13µs/call
3428103µs28346µ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
sub check_role_exclusions {
382812µs my ($self, $role, $class) = @_;
3928107µs564.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 }
4428126µs28166µ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
sub check_required_methods {
552810µs my ($self, $role, $class) = @_;
56
57284µs my @missing;
58285µ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.
662868µs28165µ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
672655µs2661µ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
692674µs522.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
772865µ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
1112859µ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
sub check_required_attributes {
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
sub apply_attributes {
1162812µs my ($self, $role, $class) = @_;
117
11828127µs28144µ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
12060293µs60266µ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 {
12660248µs180267ms $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
sub apply_methods {
1342814µs my ( $self, $role, $class ) = @_;
135
13628145µs2816.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
1373044.45ms304152µs my $method_name = $method->name;
# spent 152µs making 304 calls to Class::MOP::Method::name, avg 499ns/call
138
139304804µs304372µs next if $method->isa('Class::MOP::Method::Meta');
# spent 372µs making 304 calls to UNIVERSAL::isa, avg 1µs/call
140
141290273µs2901.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
143290238µs2904.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
14529059µs159µ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
147285276µs28516.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
153285387µs2851.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.
17628105µs2843µ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
sub apply_override_method_modifiers {
1802810µs my ($self, $role, $class) = @_;
18128146µs28249µ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 ...
1832442µs243.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
1912429µs2497µ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
1922476µs2429µ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
1942435µs243.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
sub apply_method_modifiers {
2008429µs my ($self, $modifier_type, $role, $class) = @_;
2018441µs my $add = "add_${modifier_type}_method_modifier";
2028426µs my $get = "get_${modifier_type}_method_modifiers";
20384257µs84548µ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 $_
20723110µs464.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
21114µs1;
212
213# ABSTRACT: Compose a role into a class
214
215__END__