← 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:37 2010

Filename/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Role/Application/RoleSummation.pm
StatementsExecuted 1084 statements in 20.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3118.10ms53.7msMoose::Meta::Role::Application::RoleSummation::::apply_methodsMoose::Meta::Role::Application::RoleSummation::apply_methods
22211.55ms2.39msMoose::Meta::Role::Application::RoleSummation::::get_method_aliases_for_roleMoose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role
9311.18ms3.51msMoose::Meta::Role::Application::RoleSummation::::apply_method_modifiersMoose::Meta::Role::Application::RoleSummation::apply_method_modifiers
311927µs6.43msMoose::Meta::Role::Application::RoleSummation::::check_required_methodsMoose::Meta::Role::Application::RoleSummation::check_required_methods
311887µs2.64msMoose::Meta::Role::Application::RoleSummation::::apply_override_method_modifiersMoose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers
811736µs1.12msMoose::Meta::Role::Application::RoleSummation::::get_exclusions_for_roleMoose::Meta::Role::Application::RoleSummation::get_exclusions_for_role
311678µs1.18msMoose::Meta::Role::Application::RoleSummation::::check_role_exclusionsMoose::Meta::Role::Application::RoleSummation::check_role_exclusions
1411604µs2.08msMoose::Meta::Role::Application::RoleSummation::::is_aliased_methodMoose::Meta::Role::Application::RoleSummation::is_aliased_method
311270µs525µsMoose::Meta::Role::Application::RoleSummation::::apply_attributesMoose::Meta::Role::Application::RoleSummation::apply_attributes
11172µs90µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@3Moose::Meta::Role::Application::RoleSummation::BEGIN@3
11149µs242µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@7Moose::Meta::Role::Application::RoleSummation::BEGIN@7
11141µs108µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@4Moose::Meta::Role::Application::RoleSummation::BEGIN@4
11140µs319µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@15Moose::Meta::Role::Application::RoleSummation::BEGIN@15
11138µs2.72msMoose::Meta::Role::Application::RoleSummation::::BEGIN@5Moose::Meta::Role::Application::RoleSummation::BEGIN@5
11127µs27µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@9Moose::Meta::Role::Application::RoleSummation::BEGIN@9
31122µs22µsMoose::Meta::Role::Application::RoleSummation::::check_required_attributesMoose::Meta::Role::Application::RoleSummation::check_required_attributes
0000s0sMoose::Meta::Role::Application::RoleSummation::::__ANON__[:19]Moose::Meta::Role::Application::RoleSummation::__ANON__[:19]
0000s0sMoose::Meta::Role::Application::RoleSummation::::is_method_aliasedMoose::Meta::Role::Application::RoleSummation::is_method_aliased
0000s0sMoose::Meta::Role::Application::RoleSummation::::is_method_excludedMoose::Meta::Role::Application::RoleSummation::is_method_excluded
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::RoleSummation;
2
33101µs2109µs
# spent 90µs (72+18) within Moose::Meta::Role::Application::RoleSummation::BEGIN@3 which was called: # once (72µs+18µs) by Moose::BEGIN@30 at line 3
use strict;
# spent 90µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@3 # spent 18µs making 1 call to strict::import
4398µs2175µs
# spent 108µs (41+67) within Moose::Meta::Role::Application::RoleSummation::BEGIN@4 which was called: # once (41µs+67µs) by Moose::BEGIN@30 at line 4
use warnings;
# spent 108µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@4 # spent 67µs making 1 call to warnings::import
53145µs25.41ms
# spent 2.72ms (38µs+2.68) within Moose::Meta::Role::Application::RoleSummation::BEGIN@5 which was called: # once (38µs+2.68ms) by Moose::BEGIN@30 at line 5
use metaclass;
# spent 2.72ms making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@5 # spent 2.68ms making 1 call to metaclass::import
6
73144µs2434µs
# spent 242µs (49+193) within Moose::Meta::Role::Application::RoleSummation::BEGIN@7 which was called: # once (49µs+193µs) by Moose::BEGIN@30 at line 7
use Scalar::Util 'blessed';
# spent 242µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@7 # spent 193µs making 1 call to Exporter::import
8
93235µs127µs
# spent 27µs within Moose::Meta::Role::Application::RoleSummation::BEGIN@9 which was called: # once (27µs+0s) by Moose::BEGIN@30 at line 9
use Moose::Meta::Role::Composite;
10
1115µsour $VERSION = '1.19';
12181µs$VERSION = eval $VERSION;
# spent 12µs executing statements in string eval
1313µsour $AUTHORITY = 'cpan:STEVAN';
14
1534.58ms2597µs
# spent 319µs (40+279) within Moose::Meta::Role::Application::RoleSummation::BEGIN@15 which was called: # once (40µs+279µs) by Moose::BEGIN@30 at line 15
use base 'Moose::Meta::Role::Application';
# spent 319µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@15 # spent 278µs making 1 call to base::import
16
17__PACKAGE__->meta->add_attribute('role_params' => (
18 reader => 'role_params',
19 default => sub { {} }
20134µs22.14ms));
21
22
# spent 1.12ms (736µs+386µs) within Moose::Meta::Role::Application::RoleSummation::get_exclusions_for_role which was called 8 times, avg 140µs/call: # 8 times (736µs+386µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 158, avg 140µs/call
sub get_exclusions_for_role {
23830µs my ($self, $role) = @_;
248260µs1680µs $role = $role->name if blessed $role;
# spent 40µs making 8 calls to Scalar::Util::blessed, avg 5µs/call # spent 40µs making 8 calls to Class::MOP::Package::name, avg 5µs/call
258103µs886µs my $excludes_key = exists $self->role_params->{$role}->{'-excludes'} ?
# spent 86µs making 8 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 11µs/call
26 '-excludes' : 'excludes';
278159µs16160µs if ($self->role_params->{$role} && defined $self->role_params->{$role}->{$excludes_key}) {
# spent 160µs making 16 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 10µs/call
283869µs660µs if (ref $self->role_params->{$role}->{$excludes_key} eq 'ARRAY') {
# spent 60µs making 6 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 10µs/call
29 return $self->role_params->{$role}->{$excludes_key};
30 }
31 return [ $self->role_params->{$role}->{$excludes_key} ];
32 }
33565µs return [];
34}
35
36
# spent 2.39ms (1.55+838µs) within Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role which was called 22 times, avg 108µs/call: # 14 times (915µs+498µs) by Moose::Meta::Role::Application::RoleSummation::is_aliased_method at line 62, avg 101µs/call # 8 times (632µs+340µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 157, avg 122µs/call
sub get_method_aliases_for_role {
372277µs my ($self, $role) = @_;
3822462µs30144µs $role = $role->name if blessed $role;
# spent 103µs making 22 calls to Scalar::Util::blessed, avg 5µs/call # spent 41µs making 8 calls to Class::MOP::Package::name, avg 5µs/call
3922294µs22255µs my $alias_key = exists $self->role_params->{$role}->{'-alias'} ?
# spent 255µs making 22 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 12µs/call
40 '-alias' : 'alias';
4122424µs44439µs if ($self->role_params->{$role} && defined $self->role_params->{$role}->{$alias_key}) {
# spent 439µs making 44 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 10µs/call
42 return $self->role_params->{$role}->{$alias_key};
43 }
4422308µs return {};
45}
46
47sub is_method_excluded {
48 my ($self, $role, $method_name) = @_;
49 foreach ($self->get_exclusions_for_role($role->name)) {
50 return 1 if $_ eq $method_name;
51 }
52 return 0;
53}
54
55sub is_method_aliased {
56 my ($self, $role, $method_name) = @_;
57 exists $self->get_method_aliases_for_role($role->name)->{$method_name} ? 1 : 0
58}
59
60
# spent 2.08ms (604µs+1.48) within Moose::Meta::Role::Application::RoleSummation::is_aliased_method which was called 14 times, avg 149µs/call: # 14 times (604µs+1.48ms) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 103, avg 149µs/call
sub is_aliased_method {
611458µs my ($self, $role, $method_name) = @_;
6214384µs281.48ms my %aliased_names = reverse %{$self->get_method_aliases_for_role($role->name)};
# spent 1.41ms making 14 calls to Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role, avg 101µs/call # spent 65µs making 14 calls to Class::MOP::Package::name, avg 5µs/call
6314191µs exists $aliased_names{$method_name} ? 1 : 0;
64}
65
66
# spent 1.18ms (678µs+497µs) within Moose::Meta::Role::Application::RoleSummation::check_role_exclusions which was called 3 times, avg 392µs/call: # 3 times (678µs+497µs) by Moose::Meta::Role::Application::apply at line 50 of Moose/Meta/Role/Application.pm, avg 392µs/call
sub check_role_exclusions {
67310µs my ($self, $c) = @_;
68
6936µs my %excluded_roles;
70357µs340µs for my $role (@{ $c->get_roles }) {
# spent 40µs making 3 calls to Moose::Meta::Role::get_roles, avg 13µs/call
718155µs846µs my $name = $role->name;
# spent 46µs making 8 calls to Class::MOP::Package::name, avg 6µs/call
72
738147µs8326µs for my $excluded ($role->get_excluded_roles_list) {
# spent 326µs making 8 calls to Moose::Meta::Role::get_excluded_roles_list, avg 41µs/call
74 push @{ $excluded_roles{$excluded} }, $name;
75 }
76 }
77
78341µs331µs foreach my $role (@{$c->get_roles}) {
# spent 31µs making 3 calls to Moose::Meta::Role::get_roles, avg 10µs/call
79873µs foreach my $excluded (keys %excluded_roles) {
80 next unless $role->does_role($excluded);
81
82 my @excluding = @{ $excluded_roles{$excluded} };
83
84 require Moose;
85 Moose->throw_error(sprintf "Conflict detected: Role%s %s exclude%s role '%s'", (@excluding == 1 ? '' : 's'), join(', ', @excluding), (@excluding == 1 ? 's' : ''), $excluded);
86 }
87 }
88
893172µs355µs $c->add_excluded_roles(keys %excluded_roles);
# spent 55µs making 3 calls to Moose::Meta::Role::add_excluded_roles, avg 18µs/call
90}
91
92
# spent 6.43ms (927µs+5.50) within Moose::Meta::Role::Application::RoleSummation::check_required_methods which was called 3 times, avg 2.14ms/call: # 3 times (927µs+5.50ms) by Moose::Meta::Role::Application::apply at line 51 of Moose/Meta/Role/Application.pm, avg 2.14ms/call
sub check_required_methods {
9339µs my ($self, $c) = @_;
94
95561µs574µs my %all_required_methods =
# spent 74µs making 5 calls to Moose::Meta::Role::Method::Required::name, avg 15µs/call
96881µs8290µs map { $_->name => $_ }
# spent 290µs making 8 calls to Moose::Meta::Role::get_required_method_list, avg 36µs/call
97 map { $_->get_required_method_list }
98382µs330µs @{$c->get_roles};
# spent 30µs making 3 calls to Moose::Meta::Role::get_roles, avg 10µs/call
99
100344µs332µs foreach my $role (@{$c->get_roles}) {
# spent 32µs making 3 calls to Moose::Meta::Role::get_roles, avg 11µs/call
101880µs foreach my $required (keys %all_required_methods) {
102
10314319µs284.62ms delete $all_required_methods{$required}
# spent 2.54ms making 14 calls to Class::MOP::Mixin::HasMethods::has_method, avg 181µs/call # spent 2.08ms making 14 calls to Moose::Meta::Role::Application::RoleSummation::is_aliased_method, avg 149µs/call
104 if $role->has_method($required)
105 || $self->is_aliased_method($role, $required);
106 }
107 }
108
109390µs3452µs $c->add_required_methods(values %all_required_methods);
# spent 452µs making 3 calls to Moose::Meta::Role::add_required_methods, avg 151µs/call
110}
111
112335µs
# spent 22µs within Moose::Meta::Role::Application::RoleSummation::check_required_attributes which was called 3 times, avg 7µs/call: # 3 times (22µ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 {
113
114}
115
116
# spent 525µs (270+254) within Moose::Meta::Role::Application::RoleSummation::apply_attributes which was called 3 times, avg 175µs/call: # 3 times (270µs+254µs) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 175µs/call
sub apply_attributes {
117310µs my ($self, $c) = @_;
118
11937µs my @all_attributes;
120
121343µs334µs for my $role ( @{ $c->get_roles } ) {
# spent 34µs making 3 calls to Moose::Meta::Role::get_roles, avg 11µs/call
122 push @all_attributes,
1238116µs8221µs map { $role->get_attribute($_) } $role->get_attribute_list;
# spent 221µs making 8 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 28µs/call
124 }
125
12636µs my %seen;
127315µs foreach my $attr (@all_attributes) {
128 my $name = $attr->name;
129
130 if ( exists $seen{$name} ) {
131 next if $seen{$name}->is_same_as($attr);
132
133 my $role1 = $seen{$name}->associated_role->name;
134 my $role2 = $attr->associated_role->name;
135
136 require Moose;
137 Moose->throw_error(
138 "We have encountered an attribute conflict with '$name' "
139 . "during role composition. "
140 . " This attribute is defined in both $role1 and $role2."
141 . " This is fatal error and cannot be disambiguated." );
142 }
143
144 $seen{$name} = $attr;
145 }
146
147348µs foreach my $attr (@all_attributes) {
148 $c->add_attribute( $attr->clone );
149 }
150}
151
152
# spent 53.7ms (8.10+45.6) within Moose::Meta::Role::Application::RoleSummation::apply_methods which was called 3 times, avg 17.9ms/call: # 3 times (8.10ms+45.6ms) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 17.9ms/call
sub apply_methods {
153310µs my ($self, $c) = @_;
154
155821µs my @all_methods = map {
156 my $role = $_;
157892µs8972µs my $aliases = $self->get_method_aliases_for_role($role);
# spent 972µs making 8 calls to Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role, avg 122µs/call
1588146µs81.12ms my %excludes = map { $_ => undef } @{ $self->get_exclusions_for_role($role) };
# spent 1.12ms making 8 calls to Moose::Meta::Role::Application::RoleSummation::get_exclusions_for_role, avg 140µs/call
159 (
160801.39ms765.91ms (map {
# spent 5.91ms making 76 calls to Class::MOP::Mixin::HasMethods::get_method, avg 78µs/call
161801.27ms80352µs exists $excludes{$_} ? () :
# spent 352µs making 80 calls to Class::MOP::Method::name, avg 4µs/call
162 +{
163 role => $role,
164 name => $_,
165 method => $role->get_method($_),
166 }
167881.72ms88651µs } map { $_->name }
# spent 651µs making 88 calls to UNIVERSAL::isa, avg 7µs/call
168 grep { !$_->isa('Class::MOP::Method::Meta') }
169 $role->_get_local_methods),
170 (map {
1718806µs818.7ms +{
# spent 18.7ms making 8 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 2.34ms/call
172 role => $role,
173 name => $aliases->{$_},
174 method => $role->get_method($_),
175 }
176 } keys %$aliases)
177 );
1783155µs329µs } @{$c->get_roles};
# spent 29µs making 3 calls to Moose::Meta::Role::get_roles, avg 10µs/call
179
18039µs my (%seen, %method_map);
181324µs foreach my $method (@all_methods) {
18276201µs my $seen = $seen{$method->{name}};
183
18476179µs if ($seen) {
185286µs425µs if ($seen->{method}->body != $method->{method}->body) {
# spent 25µs making 4 calls to Class::MOP::Method::body, avg 6µs/call
1862116µs6996µs $c->add_conflicting_method(
# spent 976µs making 2 calls to Moose::Meta::Role::add_conflicting_method, avg 488µs/call # spent 20µs making 4 calls to Class::MOP::Package::name, avg 5µs/call
187 name => $method->{name},
188 roles => [$method->{role}->name, $seen->{role}->name],
189 );
190
191211µs delete $method_map{$method->{name}};
19228µs next;
193 }
194 }
195
19674235µs $seen{$method->{name}} = $method;
19774374µs $method_map{$method->{name}} = $method->{method};
198 }
199
20061.08ms7216.8ms $c->add_method($_ => $method_map{$_}) for keys %method_map;
# spent 16.8ms making 72 calls to Moose::Meta::Role::Composite::add_method, avg 233µs/call
201}
202
203
# spent 2.64ms (887µs+1.75) within Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers which was called 3 times, avg 880µs/call: # 3 times (887µs+1.75ms) by Moose::Meta::Role::Application::apply at line 57 of Moose/Meta/Role/Application.pm, avg 880µs/call
sub apply_override_method_modifiers {
204311µs my ($self, $c) = @_;
205
206818µs my @all_overrides = map {
207 my $role = $_;
2089134µs9308µs map {
# spent 308µs making 9 calls to Moose::Meta::Role::get_override_method_modifier, avg 34µs/call
2098111µs8331µs +{
# spent 331µs making 8 calls to Moose::Meta::Role::get_method_modifier_list, avg 41µs/call
210 name => $_,
211 method => $role->get_override_method_modifier($_),
212 }
213 } $role->get_method_modifier_list('override');
214372µs339µs } @{$c->get_roles};
# spent 39µs making 3 calls to Moose::Meta::Role::get_roles, avg 13µs/call
215
21636µs my %seen;
217319µs foreach my $override (@all_overrides) {
2189104µs9325µs if ( $c->has_method($override->{name}) ){
# spent 325µs making 9 calls to Moose::Meta::Role::Composite::has_method, avg 36µs/call
219 require Moose;
220 Moose->throw_error( "Role '" . $c->name . "' has encountered an 'override' method conflict " .
221 "during composition (A local method of the same name as been found). This " .
222 "is fatal error." )
223 }
224927µs if (exists $seen{$override->{name}}) {
225 if ( $seen{$override->{name}} != $override->{method} ) {
226 require Moose;
227 Moose->throw_error( "We have encountered an 'override' method conflict during " .
228 "composition (Two 'override' methods of the same name encountered). " .
229 "This is fatal error.")
230 }
231 }
232967µs $seen{$override->{name}} = $override->{method};
233 }
234
235 $c->add_override_method_modifier(
236 $_->{name}, $_->{method}
2376204µs9750µs ) for @all_overrides;
# spent 750µs making 9 calls to Moose::Meta::Role::add_override_method_modifier, avg 83µs/call
238
239}
240
241
# spent 3.51ms (1.18+2.33) within Moose::Meta::Role::Application::RoleSummation::apply_method_modifiers which was called 9 times, avg 390µs/call: # 3 times (613µs+1.64ms) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 74 of Moose/Meta/Role/Application.pm, avg 750µs/call # 3 times (306µs+356µs) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 73 of Moose/Meta/Role/Application.pm, avg 221µs/call # 3 times (258µs+339µs) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 75 of Moose/Meta/Role/Application.pm, avg 199µs/call
sub apply_method_modifiers {
242933µs my ($self, $modifier_type, $c) = @_;
243937µs my $add = "add_${modifier_type}_method_modifier";
244928µs my $get = "get_${modifier_type}_method_modifiers";
2459204µs993µs foreach my $role (@{$c->get_roles}) {
# spent 93µs making 9 calls to Moose::Meta::Role::get_roles, avg 10µs/call
24624427µs24948µs foreach my $method_name ($role->get_method_modifier_list($modifier_type)) {
# spent 948µs making 24 calls to Moose::Meta::Role::get_method_modifier_list, avg 40µs/call
247 $c->$add(
248 $method_name,
249 $_
25018313µs181.29ms ) foreach $role->$get($method_name);
# spent 912µs making 9 calls to Moose::Meta::Role::add_around_method_modifier, avg 101µs/call # spent 379µs making 9 calls to Moose::Meta::Role::get_around_method_modifiers, avg 42µs/call
251 }
252 }
253}
254
255127µs1;
256
257__END__