← Index
NYTProf Performance Profile   « line view »
For examples/Atom-timer.pl
  Run on Mon Aug 12 14:45:28 2013
Reported on Mon Aug 12 14:46:15 2013

Filename/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role/Application/RoleSummation.pm
StatementsExecuted 1042 statements in 2.60ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
311774µs9.58msMoose::Meta::Role::Application::RoleSummation::::apply_methodsMoose::Meta::Role::Application::RoleSummation::apply_methods
311175µs1.25msMoose::Meta::Role::Application::RoleSummation::::apply_attributesMoose::Meta::Role::Application::RoleSummation::apply_attributes
1621148µs201µsMoose::Meta::Role::Application::RoleSummation::::get_method_aliases_for_roleMoose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role
931124µs292µsMoose::Meta::Role::Application::RoleSummation::::apply_method_modifiersMoose::Meta::Role::Application::RoleSummation::apply_method_modifiers
311120µs553µsMoose::Meta::Role::Application::RoleSummation::::check_required_methodsMoose::Meta::Role::Application::RoleSummation::check_required_methods
311101µs153µsMoose::Meta::Role::Application::RoleSummation::::check_role_exclusionsMoose::Meta::Role::Application::RoleSummation::check_role_exclusions
31196µs226µsMoose::Meta::Role::Application::RoleSummation::::apply_override_method_modifiersMoose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers
81179µs105µsMoose::Meta::Role::Application::RoleSummation::::get_exclusions_for_roleMoose::Meta::Role::Application::RoleSummation::get_exclusions_for_role
81145µs137µsMoose::Meta::Role::Application::RoleSummation::::is_aliased_methodMoose::Meta::Role::Application::RoleSummation::is_aliased_method
1119µs9µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@2Moose::Meta::Role::Application::RoleSummation::BEGIN@2
1116µs9µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@10Moose::Meta::Role::Application::RoleSummation::BEGIN@10
1116µs26µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@13Moose::Meta::Role::Application::RoleSummation::BEGIN@13
1116µs16µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@9Moose::Meta::Role::Application::RoleSummation::BEGIN@9
1116µs54µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@17Moose::Meta::Role::Application::RoleSummation::BEGIN@17
1115µs326µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@11Moose::Meta::Role::Application::RoleSummation::BEGIN@11
1113µs3µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@15Moose::Meta::Role::Application::RoleSummation::BEGIN@15
3112µs2µsMoose::Meta::Role::Application::RoleSummation::::check_required_attributesMoose::Meta::Role::Application::RoleSummation::check_required_attributes
0000s0sMoose::Meta::Role::Application::RoleSummation::::__ANON__[:21]Moose::Meta::Role::Application::RoleSummation::__ANON__[:21]
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
# spent 9µs within Moose::Meta::Role::Application::RoleSummation::BEGIN@2 which was called: # once (9µs+0s) by Moose::BEGIN@38 at line 4
BEGIN {
314µs $Moose::Meta::Role::Application::RoleSummation::AUTHORITY = 'cpan:STEVAN';
4129µs19µs}
5{
62700ns $Moose::Meta::Role::Application::RoleSummation::VERSION = '2.1005';
7}
8
9223µs226µs
# spent 16µs (6+10) within Moose::Meta::Role::Application::RoleSummation::BEGIN@9 which was called: # once (6µs+10µs) by Moose::BEGIN@38 at line 9
use strict;
# spent 16µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@9 # spent 10µs making 1 call to strict::import
10218µs212µs
# spent 9µs (6+3) within Moose::Meta::Role::Application::RoleSummation::BEGIN@10 which was called: # once (6µs+3µs) by Moose::BEGIN@38 at line 10
use warnings;
# spent 9µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@10 # spent 3µs making 1 call to warnings::import
11225µs2647µs
# spent 326µs (5+321) within Moose::Meta::Role::Application::RoleSummation::BEGIN@11 which was called: # once (5µs+321µs) by Moose::BEGIN@38 at line 11
use metaclass;
# spent 326µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@11 # spent 321µs making 1 call to metaclass::import
12
13225µs246µs
# spent 26µs (6+20) within Moose::Meta::Role::Application::RoleSummation::BEGIN@13 which was called: # once (6µs+20µs) by Moose::BEGIN@38 at line 13
use Scalar::Util 'blessed';
# spent 26µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@13 # spent 20µs making 1 call to Exporter::import
14
15222µs13µs
# spent 3µs within Moose::Meta::Role::Application::RoleSummation::BEGIN@15 which was called: # once (3µs+0s) by Moose::BEGIN@38 at line 15
use Moose::Meta::Role::Composite;
16
1721.17ms2102µs
# spent 54µs (6+48) within Moose::Meta::Role::Application::RoleSummation::BEGIN@17 which was called: # once (6µs+48µs) by Moose::BEGIN@38 at line 17
use base 'Moose::Meta::Role::Application';
# spent 54µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@17 # spent 48µs making 1 call to base::import
18
19__PACKAGE__->meta->add_attribute('role_params' => (
20 reader => 'role_params',
21 default => sub { {} },
2215µs3297µs Class::MOP::_definition_context(),
# spent 278µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 15µs making 1 call to Moose::Meta::Role::Application::RoleSummation::meta # spent 5µs making 1 call to Class::MOP::_definition_context
23));
24
25
# spent 105µs (79+26) within Moose::Meta::Role::Application::RoleSummation::get_exclusions_for_role which was called 8 times, avg 13µs/call: # 8 times (79µs+26µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 161, avg 13µs/call
sub get_exclusions_for_role {
2681µs my ($self, $role) = @_;
27830µs167µs $role = $role->name if blessed $role;
# spent 4µs making 8 calls to Scalar::Util::blessed, avg 438ns/call # spent 3µs making 8 calls to Class::MOP::Package::name, avg 400ns/call
2888µs87µs my $excludes_key = exists $self->role_params->{$role}->{'-excludes'} ?
# spent 7µs making 8 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 862ns/call
29 '-excludes' : 'excludes';
30812µs1612µs if ($self->role_params->{$role} && defined $self->role_params->{$role}->{$excludes_key}) {
# spent 12µs making 16 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 756ns/call
31 if (ref $self->role_params->{$role}->{$excludes_key} eq 'ARRAY') {
32 return $self->role_params->{$role}->{$excludes_key};
33 }
34 return [ $self->role_params->{$role}->{$excludes_key} ];
35 }
36815µs return [];
37}
38
39
# spent 201µs (148+53) within Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role which was called 16 times, avg 13µs/call: # 8 times (83µs+30µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 160, avg 14µs/call # 8 times (65µs+23µs) by Moose::Meta::Role::Application::RoleSummation::is_aliased_method at line 65, avg 11µs/call
sub get_method_aliases_for_role {
40163µs my ($self, $role) = @_;
411646µs2411µs $role = $role->name if blessed $role;
# spent 7µs making 16 calls to Scalar::Util::blessed, avg 419ns/call # spent 4µs making 8 calls to Class::MOP::Package::name, avg 488ns/call
421620µs1618µs my $alias_key = exists $self->role_params->{$role}->{'-alias'} ?
# spent 18µs making 16 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 1µs/call
43 '-alias' : 'alias';
441623µs3224µs if ($self->role_params->{$role} && defined $self->role_params->{$role}->{$alias_key}) {
# spent 24µs making 32 calls to Moose::Meta::Role::Application::RoleSummation::role_params, avg 756ns/call
45 return $self->role_params->{$role}->{$alias_key};
46 }
471630µs return {};
48}
49
50sub is_method_excluded {
51 my ($self, $role, $method_name) = @_;
52 foreach ($self->get_exclusions_for_role($role->name)) {
53 return 1 if $_ eq $method_name;
54 }
55 return 0;
56}
57
58sub is_method_aliased {
59 my ($self, $role, $method_name) = @_;
60 exists $self->get_method_aliases_for_role($role->name)->{$method_name} ? 1 : 0
61}
62
63
# spent 137µs (45+92) within Moose::Meta::Role::Application::RoleSummation::is_aliased_method which was called 8 times, avg 17µs/call: # 8 times (45µs+92µs) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 106, avg 17µs/call
sub is_aliased_method {
6482µs my ($self, $role, $method_name) = @_;
65828µs1692µs my %aliased_names = reverse %{$self->get_method_aliases_for_role($role->name)};
# spent 88µs making 8 calls to Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role, avg 11µs/call # spent 3µs making 8 calls to Class::MOP::Package::name, avg 400ns/call
66815µs exists $aliased_names{$method_name} ? 1 : 0;
67}
68
69
# spent 153µs (101+52) within Moose::Meta::Role::Application::RoleSummation::check_role_exclusions which was called 3 times, avg 51µs/call: # 3 times (101µs+52µs) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 51µs/call
sub check_role_exclusions {
703900ns my ($self, $c) = @_;
71
723700ns my %excluded_roles;
7337µs34µs for my $role (@{ $c->get_roles }) {
# spent 4µs making 3 calls to Moose::Meta::Role::get_roles, avg 1µs/call
74818µs84µs my $name = $role->name;
# spent 4µs making 8 calls to Class::MOP::Package::name, avg 538ns/call
75
76824µs833µs for my $excluded ($role->get_excluded_roles_list) {
# spent 33µs making 8 calls to Moose::Meta::Role::get_excluded_roles_list, avg 4µs/call
77 push @{ $excluded_roles{$excluded} }, $name;
78 }
79 }
80
8134µs33µs foreach my $role (@{$c->get_roles}) {
# spent 3µs making 3 calls to Moose::Meta::Role::get_roles, avg 900ns/call
8285µs foreach my $excluded (keys %excluded_roles) {
83 next unless $role->does_role($excluded);
84
85 my @excluding = @{ $excluded_roles{$excluded} };
86
87 require Moose;
88 Moose->throw_error(sprintf "Conflict detected: Role%s %s exclude%s role '%s'", (@excluding == 1 ? '' : 's'), join(', ', @excluding), (@excluding == 1 ? 's' : ''), $excluded);
89 }
90 }
91
92313µs38µs $c->add_excluded_roles(keys %excluded_roles);
# spent 8µs making 3 calls to Moose::Meta::Role::add_excluded_roles, avg 3µs/call
93}
94
95
# spent 553µs (120+433) within Moose::Meta::Role::Application::RoleSummation::check_required_methods which was called 3 times, avg 184µs/call: # 3 times (120µs+433µs) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 184µs/call
sub check_required_methods {
9631µs my ($self, $c) = @_;
97
9855µs56µs my %all_required_methods =
# spent 6µs making 5 calls to Moose::Meta::Role::Method::Required::name, avg 1µs/call
9987µs830µs map { $_->name => $_ }
# spent 30µs making 8 calls to Moose::Meta::Role::get_required_method_list, avg 4µs/call
100 map { $_->get_required_method_list }
101311µs32µs @{$c->get_roles};
# spent 2µs making 3 calls to Moose::Meta::Role::get_roles, avg 833ns/call
102
10334µs33µs foreach my $role (@{$c->get_roles}) {
# spent 3µs making 3 calls to Moose::Meta::Role::get_roles, avg 1µs/call
10486µs foreach my $required (keys %all_required_methods) {
105
1061024µs18362µs delete $all_required_methods{$required}
# spent 225µs making 10 calls to Class::MOP::Mixin::HasMethods::has_method, avg 22µs/call # spent 137µs making 8 calls to Moose::Meta::Role::Application::RoleSummation::is_aliased_method, avg 17µs/call
107 if $role->has_method($required)
108 || $self->is_aliased_method($role, $required);
109 }
110 }
111
112311µs330µs $c->add_required_methods(values %all_required_methods);
# spent 30µs making 3 calls to Moose::Meta::Role::add_required_methods, avg 10µs/call
113}
114
11536µs
# spent 2µs within Moose::Meta::Role::Application::RoleSummation::check_required_attributes which was called 3 times, avg 800ns/call: # 3 times (2µs+0s) by Moose::Meta::Role::Application::apply at line 56 of Moose/Meta/Role/Application.pm, avg 800ns/call
sub check_required_attributes {
116
117}
118
119
# spent 1.25ms (175µs+1.08) within Moose::Meta::Role::Application::RoleSummation::apply_attributes which was called 3 times, avg 418µs/call: # 3 times (175µs+1.08ms) by Moose::Meta::Role::Application::apply at line 58 of Moose/Meta/Role/Application.pm, avg 418µs/call
sub apply_attributes {
1203800ns my ($self, $c) = @_;
121
1223600ns my @all_attributes;
123
12434µs33µs for my $role ( @{ $c->get_roles } ) {
# spent 3µs making 3 calls to Moose::Meta::Role::get_roles, avg 1µs/call
1251714µs1744µs push @all_attributes,
# spent 44µs making 17 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 3µs/call
126814µs824µs map { $role->get_attribute($_) } $role->get_attribute_list;
# spent 24µs making 8 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 3µs/call
127 }
128
1293500ns my %seen;
13032µs foreach my $attr (@all_attributes) {
1311729µs176µs my $name = $attr->name;
# spent 6µs making 17 calls to Class::MOP::Mixin::AttributeCore::name, avg 376ns/call
132
133172µs if ( exists $seen{$name} ) {
134 next if $seen{$name}->is_same_as($attr);
135
136 my $role1 = $seen{$name}->associated_role->name;
137 my $role2 = $attr->associated_role->name;
138
139 require Moose;
140 Moose->throw_error(
141 "We have encountered an attribute conflict with '$name' "
142 . "during role composition. "
143 . " This attribute is defined in both $role1 and $role2."
144 . " This is a fatal error and cannot be disambiguated." );
145 }
146
147177µs $seen{$name} = $attr;
148 }
149
15039µs foreach my $attr (@all_attributes) {
1511732µs341.00ms $c->add_attribute( $attr->clone );
# spent 653µs making 17 calls to Moose::Meta::Role::add_attribute, avg 38µs/call # spent 348µs making 17 calls to Moose::Meta::Role::Attribute::clone, avg 20µs/call
152 }
153}
154
155
# spent 9.58ms (774µs+8.81) within Moose::Meta::Role::Application::RoleSummation::apply_methods which was called 3 times, avg 3.19ms/call: # 3 times (774µs+8.81ms) by Moose::Meta::Role::Application::apply at line 59 of Moose/Meta/Role/Application.pm, avg 3.19ms/call
sub apply_methods {
1563800ns my ($self, $c) = @_;
157
15881µs my @all_methods = map {
159 my $role = $_;
16089µs8113µs my $aliases = $self->get_method_aliases_for_role($role);
# spent 113µs making 8 calls to Moose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role, avg 14µs/call
161810µs8105µs my %excludes = map { $_ => undef } @{ $self->get_exclusions_for_role($role) };
# spent 105µs making 8 calls to Moose::Meta::Role::Application::RoleSummation::get_exclusions_for_role, avg 13µs/call
162 (
16363102µs63592µs (map {
# spent 592µs making 63 calls to Class::MOP::Mixin::HasMethods::get_method, avg 9µs/call
16463110µs6322µs exists $excludes{$_} ? () :
# spent 22µs making 63 calls to Class::MOP::Method::name, avg 343ns/call
165 +{
166 role => $role,
167 name => $_,
168 method => $role->get_method($_),
169 }
17071149µs7148µs } map { $_->name }
# spent 48µs making 71 calls to UNIVERSAL::isa, avg 682ns/call
171 grep { !$_->isa('Class::MOP::Method::Meta') }
172 $role->_get_local_methods),
173 (map {
174859µs83.11ms +{
# spent 3.11ms making 8 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 389µs/call
175 role => $role,
176 name => $aliases->{$_},
177 method => $role->get_method($_),
178 }
179 } keys %$aliases)
180 );
181317µs33µs } @{$c->get_roles};
# spent 3µs making 3 calls to Moose::Meta::Role::get_roles, avg 900ns/call
182
1833700ns my (%seen, %conflicts, %method_map);
18432µs foreach my $method (@all_methods) {
185638µs next if $conflicts{$method->{name}};
1866312µs my $seen = $seen{$method->{name}};
187
18863700ns if ($seen) {
189213µs42µs if ($seen->{method}->body != $method->{method}->body) {
# spent 2µs making 4 calls to Class::MOP::Method::body, avg 575ns/call
190215µs6127µs $c->add_conflicting_method(
# spent 125µs making 2 calls to Moose::Meta::Role::add_conflicting_method, avg 63µs/call # spent 1µs making 4 calls to Class::MOP::Package::name, avg 350ns/call
191 name => $method->{name},
192 roles => [$method->{role}->name, $seen->{role}->name],
193 );
194
19521µs delete $method_map{$method->{name}};
1962800ns $conflicts{$method->{name}} = 1;
1972800ns next;
198 }
199 }
200
2016116µs $seen{$method->{name}} = $method;
2026123µs $method_map{$method->{name}} = $method->{method};
203 }
204
205386µs594.69ms $c->add_method($_ => $method_map{$_}) for keys %method_map;
# spent 4.69ms making 59 calls to Moose::Meta::Role::Composite::add_method, avg 80µs/call
206}
207
208
# spent 226µs (96+130) within Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers which was called 3 times, avg 75µs/call: # 3 times (96µs+130µs) by Moose::Meta::Role::Application::apply at line 61 of Moose/Meta/Role/Application.pm, avg 75µs/call
sub apply_override_method_modifiers {
2093800ns my ($self, $c) = @_;
210
21181µs my @all_overrides = map {
212 my $role = $_;
21368µs619µs map {
# spent 19µs making 6 calls to Moose::Meta::Role::get_override_method_modifier, avg 3µs/call
214810µs836µs +{
# spent 36µs making 8 calls to Moose::Meta::Role::get_method_modifier_list, avg 5µs/call
215 name => $_,
216 method => $role->get_override_method_modifier($_),
217 }
218 } $role->get_method_modifier_list('override');
21937µs33µs } @{$c->get_roles};
# spent 3µs making 3 calls to Moose::Meta::Role::get_roles, avg 933ns/call
220
2213600ns my %seen;
22232µs foreach my $override (@all_overrides) {
22367µs623µs if ( $c->has_method($override->{name}) ){
# spent 23µs making 6 calls to Moose::Meta::Role::Composite::has_method, avg 4µs/call
224 require Moose;
225 Moose->throw_error( "Role '" . $c->name . "' has encountered an 'override' method conflict " .
226 "during composition (A local method of the same name as been found). This " .
227 "is fatal error." )
228 }
22962µs if (exists $seen{$override->{name}}) {
230 if ( $seen{$override->{name}} != $override->{method} ) {
231 require Moose;
232 Moose->throw_error( "We have encountered an 'override' method conflict during " .
233 "composition (Two 'override' methods of the same name encountered). " .
234 "This is fatal error.")
235 }
236 }
23764µs $seen{$override->{name}} = $override->{method};
238 }
239
240 $c->add_override_method_modifier(
241 $_->{name}, $_->{method}
242319µs649µs ) for @all_overrides;
# spent 49µs making 6 calls to Moose::Meta::Role::add_override_method_modifier, avg 8µs/call
243
244}
245
246
# spent 292µs (124+168) within Moose::Meta::Role::Application::RoleSummation::apply_method_modifiers which was called 9 times, avg 32µs/call: # 3 times (56µs+99µs) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 78 of Moose/Meta/Role/Application.pm, avg 52µs/call # 3 times (40µs+34µs) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 77 of Moose/Meta/Role/Application.pm, avg 24µs/call # 3 times (29µs+34µs) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 79 of Moose/Meta/Role/Application.pm, avg 21µs/call
sub apply_method_modifiers {
24793µs my ($self, $modifier_type, $c) = @_;
24894µs my $add = "add_${modifier_type}_method_modifier";
24992µs my $get = "get_${modifier_type}_method_modifiers";
250923µs98µs foreach my $role (@{$c->get_roles}) {
# spent 8µs making 9 calls to Moose::Meta::Role::get_roles, avg 833ns/call
2512432µs2495µs foreach my $method_name ($role->get_method_modifier_list($modifier_type)) {
# spent 95µs making 24 calls to Moose::Meta::Role::get_method_modifier_list, avg 4µs/call
252 $c->$add(
253 $method_name,
254 $_
255515µs1065µs ) foreach $role->$get($method_name);
# spent 47µs making 5 calls to Moose::Meta::Role::add_around_method_modifier, avg 9µs/call # spent 18µs making 5 calls to Moose::Meta::Role::get_around_method_modifiers, avg 4µs/call
256 }
257 }
258}
259
26014µs1;
261
262# ABSTRACT: Combine two or more roles
263
264__END__