← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:39:01 2010
Reported on Wed Nov 17 22:07:55 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 3162 statements in 48.9ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
101119.9ms199msMoose::Meta::Role::Application::RoleSummation::::apply_methodsMoose::Meta::Role::Application::RoleSummation::apply_methods
72215.24ms8.12msMoose::Meta::Role::Application::RoleSummation::::get_method_aliases_for_roleMoose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role
30314.13ms13.2msMoose::Meta::Role::Application::RoleSummation::::apply_method_modifiersMoose::Meta::Role::Application::RoleSummation::apply_method_modifiers
10113.41ms27.7msMoose::Meta::Role::Application::RoleSummation::::check_required_methodsMoose::Meta::Role::Application::RoleSummation::check_required_methods
10113.17ms9.71msMoose::Meta::Role::Application::RoleSummation::::apply_override_method_modifiersMoose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers
24112.21ms3.37msMoose::Meta::Role::Application::RoleSummation::::get_exclusions_for_roleMoose::Meta::Role::Application::RoleSummation::get_exclusions_for_role
48112.03ms7.26msMoose::Meta::Role::Application::RoleSummation::::is_aliased_methodMoose::Meta::Role::Application::RoleSummation::is_aliased_method
10111.82ms3.36msMoose::Meta::Role::Application::RoleSummation::::check_role_exclusionsMoose::Meta::Role::Application::RoleSummation::check_role_exclusions
10111.06ms3.21msMoose::Meta::Role::Application::RoleSummation::::apply_attributesMoose::Meta::Role::Application::RoleSummation::apply_attributes
101180µs80µsMoose::Meta::Role::Application::RoleSummation::::check_required_attributesMoose::Meta::Role::Application::RoleSummation::check_required_attributes
11176µs94µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@3Moose::Meta::Role::Application::RoleSummation::BEGIN@3
11145µs211µ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µs290µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@15Moose::Meta::Role::Application::RoleSummation::BEGIN@15
11139µs3.14msMoose::Meta::Role::Application::RoleSummation::::BEGIN@5Moose::Meta::Role::Application::RoleSummation::BEGIN@5
11124µs24µ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µs2111µs
# spent 94µs (76+18) within Moose::Meta::Role::Application::RoleSummation::BEGIN@3 which was called: # once (76µs+18µs) by Moose::BEGIN@30 at line 3
use strict;
# spent 94µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@3 # spent 18µs making 1 call to strict::import
4396µ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.23ms
# spent 3.14ms (39µs+3.10) within Moose::Meta::Role::Application::RoleSummation::BEGIN@5 which was called: # once (39µs+3.10ms) by Moose::BEGIN@30 at line 5
use metaclass;
# spent 3.14ms making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@5 # spent 3.10ms making 1 call to metaclass::import
6
73111µs2378µs
# spent 211µs (45+166) within Moose::Meta::Role::Application::RoleSummation::BEGIN@7 which was called: # once (45µs+166µs) by Moose::BEGIN@30 at line 7
use Scalar::Util 'blessed';
# spent 211µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@7 # spent 166µs making 1 call to Exporter::import
8
93265µs124µs
# spent 24µs within Moose::Meta::Role::Application::RoleSummation::BEGIN@9 which was called: # once (24µs+0s) by Moose::BEGIN@30 at line 9
use Moose::Meta::Role::Composite;
10
1115µsour $VERSION = '1.19';
12176µs$VERSION = eval $VERSION;
# spent 32µs executing statements in string eval
1314µsour $AUTHORITY = 'cpan:STEVAN';
14
1534.50ms2539µs
# spent 290µs (41+249) within Moose::Meta::Role::Application::RoleSummation::BEGIN@15 which was called: # once (41µs+249µs) by Moose::BEGIN@30 at line 15
use base 'Moose::Meta::Role::Application';
# spent 290µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@15 # spent 249µs making 1 call to base::import
16
17__PACKAGE__->meta->add_attribute('role_params' => (
18 reader => 'role_params',
19 default => sub { {} }
20136µs22.24ms));
21
22
# spent 3.37ms (2.21+1.16) within Moose::Meta::Role::Application::RoleSummation::get_exclusions_for_role which was called 24 times, avg 140µs/call: # 24 times (2.21ms+1.16ms) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 158, avg 140µs/call
sub get_exclusions_for_role {
232493µs my ($self, $role) = @_;
2424761µs48238µs $role = $role->name if blessed $role;
# spent 123µs making 24 calls to Scalar::Util::blessed, avg 5µs/call # spent 115µs making 24 calls to Class::MOP::Package::name, avg 5µs/call
2524305µs24251µs my $excludes_key = exists $self->role_params->{$role}->{'-excludes'} ?
# spent 251µs making 24 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 10µs/call
26 '-excludes' : 'excludes';
2724490µs48499µs if ($self->role_params->{$role} && defined $self->role_params->{$role}->{$excludes_key}) {
# spent 499µs making 48 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 10µs/call
288281µs16169µs if (ref $self->role_params->{$role}->{$excludes_key} eq 'ARRAY') {
# spent 169µs making 16 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 11µs/call
29 return $self->role_params->{$role}->{$excludes_key};
30 }
31 return [ $self->role_params->{$role}->{$excludes_key} ];
32 }
3316208µs return [];
34}
35
36
# spent 8.12ms (5.24+2.88) within Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role which was called 72 times, avg 113µs/call: # 48 times (3.22ms+1.77ms) by Moose::Meta::Role::Application::RoleSummation::is_aliased_method at line 62, avg 104µs/call # 24 times (2.02ms+1.11ms) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 157, avg 130µs/call
sub get_method_aliases_for_role {
3772257µs my ($self, $role) = @_;
38721.51ms96471µs $role = $role->name if blessed $role;
# spent 336µs making 72 calls to Scalar::Util::blessed, avg 5µs/call # spent 136µs making 24 calls to Class::MOP::Package::name, avg 6µs/call
3972974µs72879µs my $alias_key = exists $self->role_params->{$role}->{'-alias'} ?
# spent 879µs making 72 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 12µs/call
40 '-alias' : 'alias';
41721.53ms1491.53ms if ($self->role_params->{$role} && defined $self->role_params->{$role}->{$alias_key}) {
# spent 1.53ms making 149 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 10µs/call
42 return $self->role_params->{$role}->{$alias_key};
43 }
4467847µ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 7.26ms (2.03+5.24) within Moose::Meta::Role::Application::RoleSummation::is_aliased_method which was called 48 times, avg 151µs/call: # 48 times (2.03ms+5.24ms) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 103, avg 151µs/call
sub is_aliased_method {
6148195µs my ($self, $role, $method_name) = @_;
62481.39ms965.24ms my %aliased_names = reverse %{$self->get_method_aliases_for_role($role->name)};
# spent 4.99ms making 48 calls to Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role, avg 104µs/call # spent 248µs making 48 calls to Class::MOP::Package::name, avg 5µs/call
6348694µs exists $aliased_names{$method_name} ? 1 : 0;
64}
65
66
# spent 3.36ms (1.82+1.54) within Moose::Meta::Role::Application::RoleSummation::check_role_exclusions which was called 10 times, avg 336µs/call: # 10 times (1.82ms+1.54ms) by Moose::Meta::Role::Application::apply at line 50 of Moose/Meta/Role/Application.pm, avg 336µs/call
sub check_role_exclusions {
671037µs my ($self, $c) = @_;
68
691020µs my %excluded_roles;
7010170µs10132µs for my $role (@{ $c->get_roles }) {
# spent 132µs making 10 calls to Moose::Meta::Role::get_roles, avg 13µs/call
7124484µs24153µs my $name = $role->name;
# spent 153µs making 24 calls to Class::MOP::Package::name, avg 6µs/call
72
7324472µs24943µs for my $excluded ($role->get_excluded_roles_list) {
# spent 943µs making 24 calls to Moose::Meta::Role::get_excluded_roles_list, avg 39µs/call
74 push @{ $excluded_roles{$excluded} }, $name;
75 }
76 }
77
7810145µs10122µs foreach my $role (@{$c->get_roles}) {
# spent 122µs making 10 calls to Moose::Meta::Role::get_roles, avg 12µs/call
7924237µ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
8910252µs10193µs $c->add_excluded_roles(keys %excluded_roles);
# spent 193µs making 10 calls to Moose::Meta::Role::add_excluded_roles, avg 19µs/call
90}
91
92
# spent 27.7ms (3.41+24.3) within Moose::Meta::Role::Application::RoleSummation::check_required_methods which was called 10 times, avg 2.77ms/call: # 10 times (3.41ms+24.3ms) by Moose::Meta::Role::Application::apply at line 51 of Moose/Meta/Role/Application.pm, avg 2.77ms/call
sub check_required_methods {
931034µs my ($self, $c) = @_;
94
9520239µs20268µs my %all_required_methods =
# spent 268µs making 20 calls to Moose::Meta::Role::Method::Required::name, avg 13µs/call
9624258µs24920µs map { $_->name => $_ }
# spent 920µs making 24 calls to Moose::Meta::Role::get_required_method_list, avg 38µs/call
97 map { $_->get_required_method_list }
9810296µs10108µs @{$c->get_roles};
# spent 108µs making 10 calls to Moose::Meta::Role::get_roles, avg 11µs/call
99
10010153µs10115µs foreach my $role (@{$c->get_roles}) {
# spent 115µs making 10 calls to Moose::Meta::Role::get_roles, avg 12µs/call
10124322µs foreach my $required (keys %all_required_methods) {
102
103531.25ms10121.5ms delete $all_required_methods{$required}
# spent 14.3ms making 53 calls to Class::MOP::Mixin::HasMethods::has_method, avg 269µs/call # spent 7.26ms making 48 calls to Moose::Meta::Role::Application::RoleSummation::is_aliased_method, avg 151µs/call
104 if $role->has_method($required)
105 || $self->is_aliased_method($role, $required);
106 }
107 }
108
10910276µs101.36ms $c->add_required_methods(values %all_required_methods);
# spent 1.36ms making 10 calls to Moose::Meta::Role::add_required_methods, avg 136µs/call
110}
111
11210116µs
# spent 80µs within Moose::Meta::Role::Application::RoleSummation::check_required_attributes which was called 10 times, avg 8µs/call: # 10 times (80µ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 {
113
114}
115
116
# spent 3.21ms (1.06+2.14) within Moose::Meta::Role::Application::RoleSummation::apply_attributes which was called 10 times, avg 321µs/call: # 10 times (1.06ms+2.14ms) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 321µs/call
sub apply_attributes {
1171035µs my ($self, $c) = @_;
118
1191022µs my @all_attributes;
120
12110142µs10115µs for my $role ( @{ $c->get_roles } ) {
# spent 115µs making 10 calls to Moose::Meta::Role::get_roles, avg 12µs/call
122224µs275µs push @all_attributes,
# spent 75µs making 2 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 37µs/call
12324392µs24831µs map { $role->get_attribute($_) } $role->get_attribute_list;
# spent 831µs making 24 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 35µs/call
124 }
125
1261020µs my %seen;
1271050µs foreach my $attr (@all_attributes) {
128249µs214µs my $name = $attr->name;
# spent 14µs making 2 calls to Class::MOP::Mixin::AttributeCore::name, avg 7µs/call
129
13025µs 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
144216µs $seen{$name} = $attr;
145 }
146
14710154µs foreach my $attr (@all_attributes) {
148270µs41.11ms $c->add_attribute( $attr->clone );
# spent 871µs making 2 calls to Moose::Meta::Role::add_attribute, avg 436µs/call # spent 239µs making 2 calls to Moose::Meta::Role::Attribute::clone, avg 120µs/call
149 }
150}
151
152
# spent 199ms (19.9+179) within Moose::Meta::Role::Application::RoleSummation::apply_methods which was called 10 times, avg 19.9ms/call: # 10 times (19.9ms+179ms) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 19.9ms/call
sub apply_methods {
1531036µs my ($self, $c) = @_;
154
1552460µs my @all_methods = map {
156 my $role = $_;
15724293µs243.13ms my $aliases = $self->get_method_aliases_for_role($role);
# spent 3.13ms making 24 calls to Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role, avg 130µs/call
15824473µs243.37ms my %excludes = map { $_ => undef } @{ $self->get_exclusions_for_role($role) };
# spent 3.37ms making 24 calls to Moose::Meta::Role::Application::RoleSummation::get_exclusions_for_role, avg 140µs/call
159 (
1602193.60ms18941.5ms (map {
# spent 41.5ms making 189 calls to Class::MOP::Mixin::HasMethods::get_method, avg 220µs/call
1612193.72ms2191.03ms exists $excludes{$_} ? () :
# spent 1.03ms making 219 calls to Class::MOP::Method::name, avg 5µs/call
162 +{
163 role => $role,
164 name => $_,
165 method => $role->get_method($_),
166 }
1672434.83ms2431.88ms } map { $_->name }
# spent 1.88ms making 243 calls to UNIVERSAL::isa, avg 8µs/call
168118µs1210µs grep { !$_->isa('Class::MOP::Method::Meta') }
# spent 210µs making 1 call to Class::MOP::Mixin::HasMethods::get_method
169 $role->_get_local_methods),
170 (map {
171242.27ms2484.6ms +{
# spent 84.6ms making 24 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 3.53ms/call
172 role => $role,
173 name => $aliases->{$_},
174 method => $role->get_method($_),
175 }
176 } keys %$aliases)
177 );
17810679µs10111µs } @{$c->get_roles};
# spent 111µs making 10 calls to Moose::Meta::Role::get_roles, avg 11µs/call
179
1801026µs my (%seen, %method_map);
1811074µs foreach my $method (@all_methods) {
182190501µs my $seen = $seen{$method->{name}};
183
184190329µs if ($seen) {
18511440µs22111µs if ($seen->{method}->body != $method->{method}->body) {
# spent 111µs making 22 calls to Class::MOP::Method::body, avg 5µ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
196190615µs $seen{$method->{name}} = $method;
1971901.01ms $method_map{$method->{name}} = $method->{method};
198 }
199
200202.81ms17942.8ms $c->add_method($_ => $method_map{$_}) for keys %method_map;
# spent 42.8ms making 179 calls to Moose::Meta::Role::Composite::add_method, avg 239µs/call
201}
202
203
# spent 9.71ms (3.17+6.54) within Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers which was called 10 times, avg 971µs/call: # 10 times (3.17ms+6.54ms) by Moose::Meta::Role::Application::apply at line 57 of Moose/Meta/Role/Application.pm, avg 971µs/call
sub apply_override_method_modifiers {
2041036µs my ($self, $c) = @_;
205
2062456µs my @all_overrides = map {
207 my $role = $_;
20834511µs341.18ms map {
# spent 1.18ms making 34 calls to Moose::Meta::Role::get_override_method_modifier, avg 35µs/call
20924367µs241.13ms +{
# spent 1.13ms making 24 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');
21410245µs10127µs } @{$c->get_roles};
# spent 127µs making 10 calls to Moose::Meta::Role::get_roles, avg 13µs/call
215
2161022µs my %seen;
2171064µs foreach my $override (@all_overrides) {
21834389µs341.19ms if ( $c->has_method($override->{name}) ){
# spent 1.19ms making 34 calls to Moose::Meta::Role::Composite::has_method, avg 35µ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 }
22434120µs if (exists $seen{$override->{name}}) {
225619µs 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 }
23234229µs $seen{$override->{name}} = $override->{method};
233 }
234
235 $c->add_override_method_modifier(
236 $_->{name}, $_->{method}
23720769µs342.90ms ) for @all_overrides;
# spent 2.90ms making 34 calls to Moose::Meta::Role::add_override_method_modifier, avg 85µs/call
238
239}
240
241
# spent 13.2ms (4.13+9.10) within Moose::Meta::Role::Application::RoleSummation::apply_method_modifiers which was called 30 times, avg 441µs/call: # 10 times (2.42ms+6.97ms) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 74 of Moose/Meta/Role/Application.pm, avg 939µs/call # 10 times (896µs+1.06ms) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 73 of Moose/Meta/Role/Application.pm, avg 196µs/call # 10 times (818µs+1.06ms) 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 {
24230109µs my ($self, $modifier_type, $c) = @_;
24330109µs my $add = "add_${modifier_type}_method_modifier";
2443088µs my $get = "get_${modifier_type}_method_modifiers";
24530678µs30319µs foreach my $role (@{$c->get_roles}) {
# spent 319µs making 30 calls to Moose::Meta::Role::get_roles, avg 11µs/call
246721.28ms722.93ms foreach my $method_name ($role->get_method_modifier_list($modifier_type)) {
# spent 2.93ms making 72 calls to Moose::Meta::Role::get_method_modifier_list, avg 41µs/call
247 $c->$add(
248 $method_name,
249 $_
250821.38ms845.85ms ) foreach $role->$get($method_name);
# spent 4.15ms making 43 calls to Moose::Meta::Role::add_around_method_modifier, avg 97µs/call # spent 1.69ms making 41 calls to Moose::Meta::Role::get_around_method_modifiers, avg 41µs/call
251 }
252 }
253}
254
255127µs1;
256
257__END__