| Filename | /usr/local/lib/perl/5.18.2/Moose/Meta/Role/Application/ToRole.pm |
| Statements | Executed 2201 statements in 3.82ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 14 | 1 | 1 | 5.50ms | 44.2ms | Moose::Meta::Role::Application::ToRole::apply_methods |
| 14 | 1 | 1 | 355µs | 1.86ms | Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers |
| 42 | 3 | 1 | 329µs | 1.01ms | Moose::Meta::Role::Application::ToRole::apply_method_modifiers |
| 14 | 1 | 1 | 264µs | 1.85ms | Moose::Meta::Role::Application::ToRole::check_required_methods |
| 14 | 1 | 1 | 135µs | 292µs | Moose::Meta::Role::Application::ToRole::check_role_exclusions |
| 14 | 1 | 1 | 96µs | 50.8ms | Moose::Meta::Role::Application::ToRole::apply |
| 14 | 1 | 1 | 85µs | 327µs | Moose::Meta::Role::Application::ToRole::apply_attributes |
| 14 | 1 | 1 | 15µs | 15µs | Moose::Meta::Role::Application::ToRole::check_required_attributes |
| 1 | 1 | 1 | 10µs | 22µs | Moose::Meta::Role::Application::ToRole::BEGIN@4 |
| 1 | 1 | 1 | 8µs | 130µs | Moose::Meta::Role::Application::ToRole::BEGIN@10 |
| 1 | 1 | 1 | 7µs | 25µs | Moose::Meta::Role::Application::ToRole::BEGIN@8 |
| 1 | 1 | 1 | 7µs | 12µs | Moose::Meta::Role::Application::ToRole::BEGIN@5 |
| 1 | 1 | 1 | 6µs | 381µs | Moose::Meta::Role::Application::ToRole::BEGIN@6 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Role::Application::ToRole; | ||||
| 2 | 1 | 500ns | our $VERSION = '2.1604'; | ||
| 3 | |||||
| 4 | 2 | 20µs | 2 | 35µs | # spent 22µs (10+12) within Moose::Meta::Role::Application::ToRole::BEGIN@4 which was called:
# once (10µs+12µs) by Moose::BEGIN@37 at line 4 # spent 22µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@4
# spent 12µs making 1 call to strict::import |
| 5 | 2 | 18µs | 2 | 17µs | # spent 12µs (7+5) within Moose::Meta::Role::Application::ToRole::BEGIN@5 which was called:
# once (7µs+5µs) by Moose::BEGIN@37 at line 5 # spent 12µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@5
# spent 5µs making 1 call to warnings::import |
| 6 | 2 | 25µs | 2 | 756µs | # spent 381µs (6+375) within Moose::Meta::Role::Application::ToRole::BEGIN@6 which was called:
# once (6µs+375µs) by Moose::BEGIN@37 at line 6 # spent 381µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@6
# spent 375µs making 1 call to metaclass::import |
| 7 | |||||
| 8 | 2 | 24µs | 2 | 44µs | # spent 25µs (7+18) within Moose::Meta::Role::Application::ToRole::BEGIN@8 which was called:
# once (7µs+18µs) by Moose::BEGIN@37 at line 8 # spent 25µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@8
# spent 18µs making 1 call to parent::import |
| 9 | |||||
| 10 | 2 | 552µs | 2 | 253µs | # spent 130µs (8+122) within Moose::Meta::Role::Application::ToRole::BEGIN@10 which was called:
# once (8µs+122µs) by Moose::BEGIN@37 at line 10 # spent 130µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@10
# spent 122µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
| 11 | |||||
| 12 | # spent 50.8ms (96µs+50.7) within Moose::Meta::Role::Application::ToRole::apply which was called 14 times, avg 3.63ms/call:
# 14 times (96µs+50.7ms) by Moose::Meta::Role::apply at line 472 of Moose/Meta/Role.pm, avg 3.63ms/call | ||||
| 13 | 14 | 5µs | my ($self, $role1, $role2) = @_; | ||
| 14 | 14 | 31µs | 14 | 36.0ms | $self->SUPER::apply($role1, $role2); # spent 50.5ms making 14 calls to Moose::Meta::Role::Application::apply, avg 3.60ms/call, recursion: max depth 1, sum of overlapping time 14.5ms |
| 15 | 14 | 48µs | 14 | 232µs | $role2->add_role($role1); # spent 232µs making 14 calls to Moose::Meta::Role::add_role, avg 17µs/call |
| 16 | } | ||||
| 17 | |||||
| 18 | # spent 292µs (135+157) within Moose::Meta::Role::Application::ToRole::check_role_exclusions which was called 14 times, avg 21µs/call:
# 14 times (135µs+157µs) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 21µs/call | ||||
| 19 | 14 | 5µs | my ($self, $role1, $role2) = @_; | ||
| 20 | 14 | 56µs | 28 | 97µs | if ( $role2->excludes_role($role1->name) ) { # spent 84µs making 14 calls to Moose::Meta::Role::excludes_role, avg 6µs/call
# spent 7µs making 9 calls to Class::MOP::Package::name, avg 778ns/call
# spent 5µs making 5 calls to Moose::Meta::Role::Composite::name, avg 1µs/call |
| 21 | throw_exception( ConflictDetectedInCheckRoleExclusions => role_name => $role2->name, | ||||
| 22 | excluded_role_name => $role1->name, | ||||
| 23 | ); | ||||
| 24 | } | ||||
| 25 | 14 | 58µs | 14 | 61µs | foreach my $excluded_role_name ($role1->get_excluded_roles_list) { # spent 61µs making 14 calls to Moose::Meta::Role::get_excluded_roles_list, avg 4µs/call |
| 26 | if ( $role2->does_role($excluded_role_name) ) { | ||||
| 27 | throw_exception( RoleDoesTheExcludedRole => role_name => $role2->name, | ||||
| 28 | excluded_role_name => $excluded_role_name, | ||||
| 29 | second_role_name => $role1->name, | ||||
| 30 | ); | ||||
| 31 | } | ||||
| 32 | $role2->add_excluded_roles($excluded_role_name); | ||||
| 33 | } | ||||
| 34 | } | ||||
| 35 | |||||
| 36 | # spent 1.85ms (264µs+1.58) within Moose::Meta::Role::Application::ToRole::check_required_methods which was called 14 times, avg 132µs/call:
# 14 times (264µs+1.58ms) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 132µs/call | ||||
| 37 | 14 | 5µs | my ($self, $role1, $role2) = @_; | ||
| 38 | 14 | 54µs | 14 | 72µs | foreach my $required_method ($role1->get_required_method_list) { # spent 72µs making 14 calls to Moose::Meta::Role::get_required_method_list, avg 5µs/call |
| 39 | 22 | 29µs | 22 | 34µs | my $required_method_name = $required_method->name; # spent 34µs making 22 calls to Moose::Meta::Role::Method::Required::name, avg 2µs/call |
| 40 | |||||
| 41 | 22 | 30µs | 22 | 126µs | next if $self->is_aliased_method($required_method_name); # spent 126µs making 22 calls to Moose::Meta::Role::Application::is_aliased_method, avg 6µs/call |
| 42 | |||||
| 43 | 22 | 65µs | 44 | 1.35ms | $role2->add_required_methods($required_method) # spent 1.26ms making 22 calls to Moose::Meta::Role::find_method_by_name, avg 57µs/call
# spent 73µs making 8 calls to Moose::Meta::Role::add_required_methods, avg 9µs/call
# spent 14µs making 14 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 1µs/call |
| 44 | unless $role2->find_method_by_name($required_method_name); | ||||
| 45 | } | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | 14 | 31µs | # spent 15µs within Moose::Meta::Role::Application::ToRole::check_required_attributes which was called 14 times, avg 1µs/call:
# 14 times (15µs+0s) by Moose::Meta::Role::Application::apply at line 56 of Moose/Meta/Role/Application.pm, avg 1µs/call | ||
| 49 | |||||
| 50 | } | ||||
| 51 | |||||
| 52 | # spent 327µs (85+241) within Moose::Meta::Role::Application::ToRole::apply_attributes which was called 14 times, avg 23µs/call:
# 14 times (85µs+241µs) by Moose::Meta::Role::Application::apply at line 59 of Moose/Meta/Role/Application.pm, avg 23µs/call | ||||
| 53 | 14 | 5µs | my ($self, $role1, $role2) = @_; | ||
| 54 | 14 | 56µs | 14 | 59µs | foreach my $attribute_name ($role1->get_attribute_list) { # spent 59µs making 14 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 4µs/call |
| 55 | # it if it has one already | ||||
| 56 | 2 | 7µs | 2 | 9µs | if ($role2->has_attribute($attribute_name) && # spent 9µs making 2 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 4µs/call |
| 57 | # make sure we haven't seen this one already too | ||||
| 58 | $role2->get_attribute($attribute_name) != $role1->get_attribute($attribute_name)) { | ||||
| 59 | |||||
| 60 | my $role2_name = $role2->name; | ||||
| 61 | |||||
| 62 | throw_exception( AttributeConflictInRoles => role_name => $role1->name, | ||||
| 63 | second_role_name => $role2->name, | ||||
| 64 | attribute_name => $attribute_name | ||||
| 65 | ); | ||||
| 66 | } | ||||
| 67 | else { | ||||
| 68 | 2 | 10µs | 6 | 174µs | $role2->add_attribute( # spent 97µs making 2 calls to Moose::Meta::Role::add_attribute, avg 49µs/call
# spent 67µs making 2 calls to Moose::Meta::Role::Attribute::clone, avg 34µs/call
# spent 10µs making 2 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 5µs/call |
| 69 | $role1->get_attribute($attribute_name)->clone | ||||
| 70 | ); | ||||
| 71 | } | ||||
| 72 | } | ||||
| 73 | } | ||||
| 74 | |||||
| 75 | # spent 44.2ms (5.50+38.7) within Moose::Meta::Role::Application::ToRole::apply_methods which was called 14 times, avg 3.15ms/call:
# 14 times (5.50ms+38.7ms) by Moose::Meta::Role::Application::apply at line 60 of Moose/Meta/Role/Application.pm, avg 3.15ms/call | ||||
| 76 | 14 | 6µs | my ( $self, $role1, $role2 ) = @_; | ||
| 77 | 14 | 107µs | 14 | 11.5ms | foreach my $method ( $role1->_get_local_methods ) { # spent 11.4ms making 9 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 1.27ms/call
# spent 35µs making 5 calls to Moose::Meta::Role::Composite::_get_local_methods, avg 7µs/call |
| 78 | |||||
| 79 | 238 | 479µs | 238 | 109µs | my $method_name = $method->name; # spent 109µs making 238 calls to Class::MOP::Method::name, avg 457ns/call |
| 80 | |||||
| 81 | 238 | 603µs | 238 | 279µs | next if $method->isa('Class::MOP::Method::Meta'); # spent 279µs making 238 calls to UNIVERSAL::isa, avg 1µs/call |
| 82 | |||||
| 83 | 229 | 190µs | 229 | 853µs | unless ( $self->is_method_excluded($method_name) ) { # spent 853µs making 229 calls to Moose::Meta::Role::Application::is_method_excluded, avg 4µs/call |
| 84 | |||||
| 85 | 229 | 169µs | 229 | 8.62ms | my $role2_method = $role2->get_method($method_name); # spent 8.62ms making 229 calls to Class::MOP::Mixin::HasMethods::get_method, avg 38µs/call |
| 86 | 229 | 164µs | 60 | 28µs | if ( $role2_method # spent 14µs making 20 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 710ns/call
# spent 14µs making 40 calls to Class::MOP::Method::body, avg 340ns/call |
| 87 | && $role2_method->body != $method->body ) { | ||||
| 88 | |||||
| 89 | # method conflicts between roles used to result in the method | ||||
| 90 | # becoming a requirement but now are permitted just like | ||||
| 91 | # for classes, hence no code in this branch anymore. | ||||
| 92 | } | ||||
| 93 | else { | ||||
| 94 | 209 | 181µs | 209 | 16.5ms | $role2->add_method( # spent 16.5ms making 209 calls to Class::MOP::Mixin::HasMethods::add_method, avg 79µs/call |
| 95 | $method_name, | ||||
| 96 | $method, | ||||
| 97 | ); | ||||
| 98 | } | ||||
| 99 | } | ||||
| 100 | |||||
| 101 | 229 | 277µs | 229 | 818µs | next unless $self->is_method_aliased($method_name); # spent 818µs making 229 calls to Moose::Meta::Role::Application::is_method_aliased, avg 4µs/call |
| 102 | |||||
| 103 | my $aliased_method_name = $self->get_method_aliases->{$method_name}; | ||||
| 104 | |||||
| 105 | my $role2_method = $role2->get_method($aliased_method_name); | ||||
| 106 | |||||
| 107 | if ( $role2_method | ||||
| 108 | && $role2_method->body != $method->body ) { | ||||
| 109 | |||||
| 110 | throw_exception( CannotCreateMethodAliasLocalMethodIsPresent => aliased_method_name => $aliased_method_name, | ||||
| 111 | method => $method, | ||||
| 112 | role_name => $role2->name, | ||||
| 113 | role_being_applied_name => $role1->name, | ||||
| 114 | ); | ||||
| 115 | } | ||||
| 116 | |||||
| 117 | $role2->add_method( | ||||
| 118 | $aliased_method_name, | ||||
| 119 | $role1->get_method($method_name) | ||||
| 120 | ); | ||||
| 121 | |||||
| 122 | if ( !$role2->has_method($method_name) ) { | ||||
| 123 | $role2->add_required_methods($method_name) | ||||
| 124 | unless $self->is_method_excluded($method_name); | ||||
| 125 | } | ||||
| 126 | } | ||||
| 127 | } | ||||
| 128 | |||||
| 129 | # spent 1.86ms (355µs+1.50) within Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers which was called 14 times, avg 133µs/call:
# 14 times (355µs+1.50ms) by Moose::Meta::Role::Application::apply at line 62 of Moose/Meta/Role/Application.pm, avg 133µs/call | ||||
| 130 | 14 | 6µs | my ($self, $role1, $role2) = @_; | ||
| 131 | 14 | 59µs | 14 | 102µs | foreach my $method_name ($role1->get_method_modifier_list('override')) { # spent 102µs making 14 calls to Moose::Meta::Role::get_method_modifier_list, avg 7µs/call |
| 132 | # it if it has one already then ... | ||||
| 133 | 36 | 51µs | 36 | 515µs | if ($role2->has_method($method_name)) { # spent 515µs making 36 calls to Class::MOP::Mixin::HasMethods::has_method, avg 14µs/call |
| 134 | # if it is being composed into another role | ||||
| 135 | # we have a conflict here, because you cannot | ||||
| 136 | # combine an overridden method with a locally | ||||
| 137 | # defined one | ||||
| 138 | throw_exception( OverrideConflictInComposition => role_name => $role2->name, | ||||
| 139 | role_being_applied_name => $role1->name, | ||||
| 140 | method_name => $method_name | ||||
| 141 | ); | ||||
| 142 | } | ||||
| 143 | else { | ||||
| 144 | # if we are a role, we need to make sure | ||||
| 145 | # we don't have a conflict with the role | ||||
| 146 | # we are composing into | ||||
| 147 | 36 | 43µs | 36 | 126µs | if ($role2->has_override_method_modifier($method_name) && # spent 126µs making 36 calls to Moose::Meta::Role::has_override_method_modifier, avg 4µs/call |
| 148 | $role1->get_override_method_modifier($method_name) != $role2->get_override_method_modifier($method_name)) { | ||||
| 149 | |||||
| 150 | throw_exception( OverrideConflictInComposition => role_name => $role2->name, | ||||
| 151 | role_being_applied_name => $role1->name, | ||||
| 152 | method_name => $method_name, | ||||
| 153 | two_overrides_found => 1 | ||||
| 154 | ); | ||||
| 155 | } | ||||
| 156 | else { | ||||
| 157 | # if there is no conflict, | ||||
| 158 | # just add it to the role | ||||
| 159 | 36 | 68µs | 72 | 758µs | $role2->add_override_method_modifier( # spent 648µs making 36 calls to Moose::Meta::Role::add_override_method_modifier, avg 18µs/call
# spent 109µs making 36 calls to Moose::Meta::Role::get_override_method_modifier, avg 3µs/call |
| 160 | $method_name, | ||||
| 161 | $role1->get_override_method_modifier($method_name) | ||||
| 162 | ); | ||||
| 163 | } | ||||
| 164 | } | ||||
| 165 | } | ||||
| 166 | } | ||||
| 167 | |||||
| 168 | # spent 1.01ms (329µs+683µs) within Moose::Meta::Role::Application::ToRole::apply_method_modifiers which was called 42 times, avg 24µs/call:
# 14 times (182µs+456µs) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 79 of Moose/Meta/Role/Application.pm, avg 46µs/call
# 14 times (106µs+139µs) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 78 of Moose/Meta/Role/Application.pm, avg 18µs/call
# 14 times (42µs+88µs) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 80 of Moose/Meta/Role/Application.pm, avg 9µs/call | ||||
| 169 | 42 | 18µs | my ($self, $modifier_type, $role1, $role2) = @_; | ||
| 170 | 42 | 19µs | my $add = "add_${modifier_type}_method_modifier"; | ||
| 171 | 42 | 13µs | my $get = "get_${modifier_type}_method_modifiers"; | ||
| 172 | 42 | 116µs | 42 | 234µs | foreach my $method_name ($role1->get_method_modifier_list($modifier_type)) { # spent 234µs making 42 calls to Moose::Meta::Role::get_method_modifier_list, avg 6µs/call |
| 173 | $role2->$add( | ||||
| 174 | $method_name, | ||||
| 175 | $_ | ||||
| 176 | 32 | 115µs | 64 | 449µs | ) foreach $role1->$get($method_name); # spent 272µs making 28 calls to Moose::Meta::Role::add_around_method_modifier, avg 10µs/call
# spent 112µs making 28 calls to Moose::Meta::Role::get_around_method_modifiers, avg 4µs/call
# spent 42µs making 4 calls to Moose::Meta::Role::add_before_method_modifier, avg 10µs/call
# spent 23µs making 4 calls to Moose::Meta::Role::get_before_method_modifiers, avg 6µs/call |
| 177 | } | ||||
| 178 | } | ||||
| 179 | |||||
| 180 | 1 | 2µs | 1; | ||
| 181 | |||||
| 182 | # ABSTRACT: Compose a role into another role | ||||
| 183 | |||||
| 184 | __END__ |