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

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Role/Application/RoleSummation.pm
StatementsExecuted 2884 statements in 45.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
91120.5ms203msMoose::Meta::Role::Application::RoleSummation::::apply_methodsMoose::Meta::Role::Application::RoleSummation::apply_methods
27314.14ms13.7msMoose::Meta::Role::Application::RoleSummation::::apply_method_modifiersMoose::Meta::Role::Application::RoleSummation::apply_method_modifiers
9113.70ms11.5msMoose::Meta::Role::Application::RoleSummation::::apply_override_method_modifiersMoose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers
43213.24ms4.92msMoose::Meta::Role::Application::RoleSummation::::get_method_aliases_for_roleMoose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role
9112.18ms13.7msMoose::Meta::Role::Application::RoleSummation::::check_required_methodsMoose::Meta::Role::Application::RoleSummation::check_required_methods
20111.90ms2.89msMoose::Meta::Role::Application::RoleSummation::::get_exclusions_for_roleMoose::Meta::Role::Application::RoleSummation::get_exclusions_for_role
9111.50ms2.75msMoose::Meta::Role::Application::RoleSummation::::check_role_exclusionsMoose::Meta::Role::Application::RoleSummation::check_role_exclusions
2311966µs3.45msMoose::Meta::Role::Application::RoleSummation::::is_aliased_methodMoose::Meta::Role::Application::RoleSummation::is_aliased_method
911737µs1.50msMoose::Meta::Role::Application::RoleSummation::::apply_attributesMoose::Meta::Role::Application::RoleSummation::apply_attributes
11178µs95µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@3Moose::Meta::Role::Application::RoleSummation::BEGIN@3
91167µs67µsMoose::Meta::Role::Application::RoleSummation::::check_required_attributesMoose::Meta::Role::Application::RoleSummation::check_required_attributes
11146µs3.17msMoose::Meta::Role::Application::RoleSummation::::BEGIN@5Moose::Meta::Role::Application::RoleSummation::BEGIN@5
11143µs214µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@7Moose::Meta::Role::Application::RoleSummation::BEGIN@7
11141µs110µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@4Moose::Meta::Role::Application::RoleSummation::BEGIN@4
11141µs288µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@15Moose::Meta::Role::Application::RoleSummation::BEGIN@15
11126µs26µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@9Moose::Meta::Role::Application::RoleSummation::BEGIN@9
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
33107µs2112µs
# spent 95µs (78+17) within Moose::Meta::Role::Application::RoleSummation::BEGIN@3 which was called: # once (78µs+17µs) by Moose::BEGIN@30 at line 3
use strict;
# spent 95µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@3 # spent 17µs making 1 call to strict::import
4395µs2180µs
# spent 110µs (41+69) within Moose::Meta::Role::Application::RoleSummation::BEGIN@4 which was called: # once (41µs+69µs) by Moose::BEGIN@30 at line 4
use warnings;
# spent 110µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@4 # spent 69µs making 1 call to warnings::import
53159µs26.30ms
# spent 3.17ms (46µs+3.13) within Moose::Meta::Role::Application::RoleSummation::BEGIN@5 which was called: # once (46µs+3.13ms) by Moose::BEGIN@30 at line 5
use metaclass;
# spent 3.17ms making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@5 # spent 3.13ms making 1 call to metaclass::import
6
73113µs2384µs
# spent 214µs (43+171) within Moose::Meta::Role::Application::RoleSummation::BEGIN@7 which was called: # once (43µs+171µs) by Moose::BEGIN@30 at line 7
use Scalar::Util 'blessed';
# spent 214µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@7 # spent 171µs making 1 call to Exporter::import
8
93229µs126µs
# spent 26µs within Moose::Meta::Role::Application::RoleSummation::BEGIN@9 which was called: # once (26µs+0s) by Moose::BEGIN@30 at line 9
use Moose::Meta::Role::Composite;
10
1115µsour $VERSION = '1.19';
12165µs$VERSION = eval $VERSION;
# spent 11µs executing statements in string eval
1313µsour $AUTHORITY = 'cpan:STEVAN';
14
1534.55ms2535µs
# spent 288µs (41+247) within Moose::Meta::Role::Application::RoleSummation::BEGIN@15 which was called: # once (41µs+247µs) by Moose::BEGIN@30 at line 15
use base 'Moose::Meta::Role::Application';
# spent 288µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@15 # spent 247µs making 1 call to base::import
16
17__PACKAGE__->meta->add_attribute('role_params' => (
18 reader => 'role_params',
19 default => sub { {} }
20134µs22.29ms));
21
22
# spent 2.89ms (1.90+994µs) within Moose::Meta::Role::Application::RoleSummation::get_exclusions_for_role which was called 20 times, avg 145µs/call: # 20 times (1.90ms+994µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 158, avg 145µs/call
sub get_exclusions_for_role {
231001.81ms my ($self, $role) = @_;
2440193µs $role = $role->name if blessed $role;
# spent 103µs making 20 calls to Scalar::Util::blessed, avg 5µs/call # spent 90µs making 20 calls to Class::MOP::Package::name, avg 5µs/call
2520203µs my $excludes_key = exists $self->role_params->{$role}->{'-excludes'} ?
# spent 203µs making 20 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 10µs/call
26 '-excludes' : 'excludes';
2740399µs if ($self->role_params->{$role} && defined $self->role_params->{$role}->{$excludes_key}) {
# spent 399µs making 40 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 10µs/call
2820199µs if (ref $self->role_params->{$role}->{$excludes_key} eq 'ARRAY') {
# spent 199µs making 20 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 }
33 return [];
34}
35
36
# spent 4.92ms (3.24+1.68) within Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role which was called 43 times, avg 114µs/call: # 23 times (1.55ms+819µs) by Moose::Meta::Role::Application::RoleSummation::is_aliased_method at line 62, avg 103µs/call # 20 times (1.69ms+858µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 157, avg 127µs/call
sub get_method_aliases_for_role {
372153.18ms my ($self, $role) = @_;
3863311µs $role = $role->name if blessed $role;
# spent 206µs making 43 calls to Scalar::Util::blessed, avg 5µs/call # spent 105µs making 20 calls to Class::MOP::Package::name, avg 5µs/call
3943503µs my $alias_key = exists $self->role_params->{$role}->{'-alias'} ?
# spent 503µs making 43 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 12µs/call
40 '-alias' : 'alias';
4186863µs if ($self->role_params->{$role} && defined $self->role_params->{$role}->{$alias_key}) {
# spent 863µs making 86 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 10µs/call
42 return $self->role_params->{$role}->{$alias_key};
43 }
44 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 3.45ms (966µs+2.48) within Moose::Meta::Role::Application::RoleSummation::is_aliased_method which was called 23 times, avg 150µs/call: # 23 times (966µs+2.48ms) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 103, avg 150µs/call
sub is_aliased_method {
61691.12ms my ($self, $role, $method_name) = @_;
62462.48ms my %aliased_names = reverse %{$self->get_method_aliases_for_role($role->name)};
# spent 2.37ms making 23 calls to Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role, avg 103µs/call # spent 116µs making 23 calls to Class::MOP::Package::name, avg 5µs/call
63 exists $aliased_names{$method_name} ? 1 : 0;
64}
65
66
# spent 2.75ms (1.50+1.25) within Moose::Meta::Role::Application::RoleSummation::check_role_exclusions which was called 9 times, avg 305µs/call: # 9 times (1.50ms+1.25ms) by Moose::Meta::Role::Application::apply at line 50 of Moose/Meta/Role/Application.pm, avg 305µs/call
sub check_role_exclusions {
671051.48ms my ($self, $c) = @_;
68
69 my %excluded_roles;
709116µs for my $role (@{ $c->get_roles }) {
# spent 116µs making 9 calls to Moose::Meta::Role::get_roles, avg 13µs/call
7120122µs my $name = $role->name;
# spent 122µs making 20 calls to Class::MOP::Package::name, avg 6µs/call
72
7320751µs for my $excluded ($role->get_excluded_roles_list) {
# spent 751µs making 20 calls to Moose::Meta::Role::get_excluded_roles_list, avg 38µs/call
74 push @{ $excluded_roles{$excluded} }, $name;
75 }
76 }
77
78992µs foreach my $role (@{$c->get_roles}) {
# spent 92µs making 9 calls to Moose::Meta::Role::get_roles, avg 10µs/call
79 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
899165µs $c->add_excluded_roles(keys %excluded_roles);
# spent 165µs making 9 calls to Moose::Meta::Role::add_excluded_roles, avg 18µs/call
90}
91
92
# spent 13.7ms (2.18+11.5) within Moose::Meta::Role::Application::RoleSummation::check_required_methods which was called 9 times, avg 1.52ms/call: # 9 times (2.18ms+11.5ms) by Moose::Meta::Role::Application::apply at line 51 of Moose/Meta/Role/Application.pm, avg 1.52ms/call
sub check_required_methods {
931101.81ms my ($self, $c) = @_;
94
9510148µs my %all_required_methods =
# spent 148µs making 10 calls to Moose::Meta::Role::Method::Required::name, avg 15µs/call
9620807µs map { $_->name => $_ }
# spent 807µs making 20 calls to Moose::Meta::Role::get_required_method_list, avg 40µs/call
97 map { $_->get_required_method_list }
98989µs @{$c->get_roles};
# spent 89µs making 9 calls to Moose::Meta::Role::get_roles, avg 10µs/call
99
100995µs foreach my $role (@{$c->get_roles}) {
# spent 95µs making 9 calls to Moose::Meta::Role::get_roles, avg 11µs/call
101 foreach my $required (keys %all_required_methods) {
102
103479.50ms delete $all_required_methods{$required}
# spent 6.06ms making 24 calls to Class::MOP::Mixin::HasMethods::has_method, avg 252µs/call # spent 3.45ms making 23 calls to Moose::Meta::Role::Application::RoleSummation::is_aliased_method, avg 150µs/call
104 if $role->has_method($required)
105 || $self->is_aliased_method($role, $required);
106 }
107 }
108
1099865µs $c->add_required_methods(values %all_required_methods);
# spent 865µs making 9 calls to Moose::Meta::Role::add_required_methods, avg 96µs/call
110}
111
112997µs
# spent 67µs within Moose::Meta::Role::Application::RoleSummation::check_required_attributes which was called 9 times, avg 7µs/call: # 9 times (67µ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 1.50ms (737µs+767µs) within Moose::Meta::Role::Application::RoleSummation::apply_attributes which was called 9 times, avg 167µs/call: # 9 times (737µs+767µs) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 167µs/call
sub apply_attributes {
11774668µs my ($self, $c) = @_;
118
119 my @all_attributes;
120
121995µs for my $role ( @{ $c->get_roles } ) {
# spent 95µs making 9 calls to Moose::Meta::Role::get_roles, avg 11µs/call
122 push @all_attributes,
12320672µs map { $role->get_attribute($_) } $role->get_attribute_list;
# spent 672µs making 20 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 34µs/call
124 }
125
126 my %seen;
127 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
147 foreach my $attr (@all_attributes) {
148 $c->add_attribute( $attr->clone );
149 }
150}
151
152
# spent 203ms (20.5+182) within Moose::Meta::Role::Application::RoleSummation::apply_methods which was called 9 times, avg 22.5ms/call: # 9 times (20.5ms+182ms) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 22.5ms/call
sub apply_methods {
153165422.8ms my ($self, $c) = @_;
154
155 my @all_methods = map {
156 my $role = $_;
157202.55ms my $aliases = $self->get_method_aliases_for_role($role);
# spent 2.55ms making 20 calls to Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role, avg 127µs/call
158202.89ms my %excludes = map { $_ => undef } @{ $self->get_exclusions_for_role($role) };
# spent 2.89ms making 20 calls to Moose::Meta::Role::Application::RoleSummation::get_exclusions_for_role, avg 145µs/call
159 (
16019444.9ms (map {
# spent 44.9ms making 194 calls to Class::MOP::Mixin::HasMethods::get_method, avg 232µs/call
1612361.13ms exists $excludes{$_} ? () :
# spent 1.13ms making 236 calls to Class::MOP::Method::name, avg 5µs/call
162 +{
163 role => $role,
164 name => $_,
165 method => $role->get_method($_),
166 }
1672562.03ms } map { $_->name }
# spent 2.03ms making 256 calls to UNIVERSAL::isa, avg 8µs/call
168 grep { !$_->isa('Class::MOP::Method::Meta') }
169 $role->_get_local_methods),
170 (map {
1712083.0ms +{
# spent 83.0ms making 20 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 4.15ms/call
172 role => $role,
173 name => $aliases->{$_},
174 method => $role->get_method($_),
175 }
176 } keys %$aliases)
177 );
178987µs } @{$c->get_roles};
# spent 87µs making 9 calls to Moose::Meta::Role::get_roles, avg 10µs/call
179
180 my (%seen, %method_map);
181 foreach my $method (@all_methods) {
182 my $seen = $seen{$method->{name}};
183
184 if ($seen) {
18532193µs if ($seen->{method}->body != $method->{method}->body) {
# spent 193µs making 32 calls to Class::MOP::Method::body, avg 6µs/call
186 $c->add_conflicting_method(
187 name => $method->{name},
188 roles => [$method->{role}->name, $seen->{role}->name],
189 );
190
191 delete $method_map{$method->{name}};
192 next;
193 }
194 }
195
196 $seen{$method->{name}} = $method;
197 $method_map{$method->{name}} = $method->{method};
198 }
199
20017845.2ms $c->add_method($_ => $method_map{$_}) for keys %method_map;
# spent 45.2ms making 178 calls to Moose::Meta::Role::Composite::add_method, avg 254µs/call
201}
202
203
# spent 11.5ms (3.70+7.80) within Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers which was called 9 times, avg 1.28ms/call: # 9 times (3.70ms+7.80ms) by Moose::Meta::Role::Application::apply at line 57 of Moose/Meta/Role/Application.pm, avg 1.28ms/call
sub apply_override_method_modifiers {
2042673.25ms my ($self, $c) = @_;
205
206 my @all_overrides = map {
207 my $role = $_;
208411.53ms map {
# spent 1.53ms making 41 calls to Moose::Meta::Role::get_override_method_modifier, avg 37µs/call
20920937µs +{
# spent 937µs making 20 calls to Moose::Meta::Role::get_method_modifier_list, avg 47µs/call
210 name => $_,
211 method => $role->get_override_method_modifier($_),
212 }
213 } $role->get_method_modifier_list('override');
2149117µs } @{$c->get_roles};
# spent 117µs making 9 calls to Moose::Meta::Role::get_roles, avg 13µs/call
215
216 my %seen;
217 foreach my $override (@all_overrides) {
218411.56ms if ( $c->has_method($override->{name}) ){
# spent 1.56ms making 41 calls to Moose::Meta::Role::Composite::has_method, avg 38µ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 }
224 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 }
232 $seen{$override->{name}} = $override->{method};
233 }
234
235 $c->add_override_method_modifier(
236 $_->{name}, $_->{method}
237413.66ms ) for @all_overrides;
# spent 3.66ms making 41 calls to Moose::Meta::Role::add_override_method_modifier, avg 89µs/call
238
239}
240
241
# spent 13.7ms (4.14+9.60) within Moose::Meta::Role::Application::RoleSummation::apply_method_modifiers which was called 27 times, avg 509µs/call: # 9 times (2.63ms+7.72ms) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 74 of Moose/Meta/Role/Application.pm, avg 1.15ms/call # 9 times (767µs+937µs) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 73 of Moose/Meta/Role/Application.pm, avg 189µs/call # 9 times (739µs+950µs) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 75 of Moose/Meta/Role/Application.pm, avg 188µs/call
sub apply_method_modifiers {
2422583.69ms my ($self, $modifier_type, $c) = @_;
243 my $add = "add_${modifier_type}_method_modifier";
244 my $get = "get_${modifier_type}_method_modifiers";
24527292µs foreach my $role (@{$c->get_roles}) {
# spent 292µs making 27 calls to Moose::Meta::Role::get_roles, avg 11µs/call
246602.54ms foreach my $method_name ($role->get_method_modifier_list($modifier_type)) {
# spent 2.54ms making 60 calls to Moose::Meta::Role::get_method_modifier_list, avg 42µs/call
247 $c->$add(
248 $method_name,
249 $_
250926.77ms ) foreach $role->$get($method_name);
# spent 4.78ms making 47 calls to Moose::Meta::Role::add_around_method_modifier, avg 102µs/call # spent 1.99ms making 45 calls to Moose::Meta::Role::get_around_method_modifiers, avg 44µs/call
251 }
252 }
253}
254
255128µs1;
256
257__END__