| Filename | /home/doy/coding/src/Moose/blib/lib//Moose/Meta/Role/Application/ToRole.pm |
| Statements | Executed 1921 statements in 30.7ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 18 | 1 | 1 | 16.9ms | 157ms | Moose::Meta::Role::Application::ToRole::apply_methods |
| 54 | 3 | 1 | 2.85ms | 8.90ms | Moose::Meta::Role::Application::ToRole::apply_method_modifiers |
| 18 | 1 | 1 | 2.12ms | 12.6ms | Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers |
| 18 | 1 | 1 | 1.77ms | 15.3ms | Moose::Meta::Role::Application::ToRole::check_required_methods |
| 18 | 1 | 1 | 1.14ms | 2.90ms | Moose::Meta::Role::Application::ToRole::check_role_exclusions |
| 18 | 1 | 1 | 1.06ms | 5.28ms | Moose::Meta::Role::Application::ToRole::apply_attributes |
| 18 | 1 | 1 | 1.03ms | 209ms | Moose::Meta::Role::Application::ToRole::apply |
| 18 | 1 | 1 | 141µs | 141µs | Moose::Meta::Role::Application::ToRole::check_required_attributes |
| 1 | 1 | 1 | 73µs | 90µs | Moose::Meta::Role::Application::ToRole::BEGIN@3 |
| 1 | 1 | 1 | 60µs | 224µs | Moose::Meta::Role::Application::ToRole::BEGIN@7 |
| 1 | 1 | 1 | 42µs | 109µs | Moose::Meta::Role::Application::ToRole::BEGIN@4 |
| 1 | 1 | 1 | 39µs | 283µs | Moose::Meta::Role::Application::ToRole::BEGIN@13 |
| 1 | 1 | 1 | 37µs | 2.75ms | Moose::Meta::Role::Application::ToRole::BEGIN@5 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Role::Application::ToRole; | ||||
| 2 | |||||
| 3 | 3 | 99µs | 2 | 108µs | # spent 90µs (73+18) within Moose::Meta::Role::Application::ToRole::BEGIN@3 which was called:
# once (73µs+18µs) by Moose::BEGIN@32 at line 3 # spent 90µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@3
# spent 18µs making 1 call to strict::import |
| 4 | 3 | 93µs | 2 | 177µs | # spent 109µs (42+68) within Moose::Meta::Role::Application::ToRole::BEGIN@4 which was called:
# once (42µs+68µs) by Moose::BEGIN@32 at line 4 # spent 109µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@4
# spent 68µs making 1 call to warnings::import |
| 5 | 3 | 142µs | 2 | 5.46ms | # spent 2.75ms (37µs+2.71) within Moose::Meta::Role::Application::ToRole::BEGIN@5 which was called:
# once (37µs+2.71ms) by Moose::BEGIN@32 at line 5 # spent 2.75ms making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@5
# spent 2.71ms making 1 call to metaclass::import |
| 6 | |||||
| 7 | 3 | 248µs | 2 | 388µs | # spent 224µs (60+164) within Moose::Meta::Role::Application::ToRole::BEGIN@7 which was called:
# once (60µs+164µs) by Moose::BEGIN@32 at line 7 # spent 224µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@7
# spent 164µs making 1 call to Exporter::import |
| 8 | |||||
| 9 | 1 | 5µs | our $VERSION = '1.19'; | ||
| 10 | 1 | 60µs | $VERSION = eval $VERSION; # spent 11µs executing statements in string eval | ||
| 11 | 1 | 3µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 12 | |||||
| 13 | 3 | 2.59ms | 2 | 527µs | # spent 283µs (39+244) within Moose::Meta::Role::Application::ToRole::BEGIN@13 which was called:
# once (39µs+244µs) by Moose::BEGIN@32 at line 13 # spent 283µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@13
# spent 244µs making 1 call to base::import |
| 14 | |||||
| 15 | # spent 209ms (1.03+208) within Moose::Meta::Role::Application::ToRole::apply which was called 18 times, avg 11.6ms/call:
# 18 times (1.03ms+208ms) by Moose::Meta::Role::apply at line 483 of Moose/Meta/Role.pm, avg 11.6ms/call | ||||
| 16 | 18 | 81µs | my ($self, $role1, $role2) = @_; | ||
| 17 | 18 | 545µs | 18 | 206ms | $self->SUPER::apply($role1, $role2); # spent 206ms making 18 calls to Moose::Meta::Role::Application::apply, avg 11.5ms/call |
| 18 | 18 | 365µs | 18 | 1.87ms | $role2->add_role($role1); # spent 1.87ms making 18 calls to Moose::Meta::Role::add_role, avg 104µs/call |
| 19 | } | ||||
| 20 | |||||
| 21 | # spent 2.90ms (1.14+1.77) within Moose::Meta::Role::Application::ToRole::check_role_exclusions which was called 18 times, avg 161µs/call:
# 18 times (1.14ms+1.77ms) by Moose::Meta::Role::Application::apply at line 50 of Moose/Meta/Role/Application.pm, avg 161µs/call | ||||
| 22 | 18 | 60µs | my ($self, $role1, $role2) = @_; | ||
| 23 | 18 | 687µs | 36 | 1.04ms | if ( $role2->excludes_role($role1->name) ) { # spent 853µs making 18 calls to Moose::Meta::Role::excludes_role, avg 47µs/call
# spent 159µs making 16 calls to Class::MOP::Package::name, avg 10µs/call
# spent 32µs making 2 calls to Moose::Meta::Role::Composite::name, avg 16µs/call |
| 24 | require Moose; | ||||
| 25 | Moose->throw_error("Conflict detected: " . $role2->name . " excludes role '" . $role1->name . "'"); | ||||
| 26 | } | ||||
| 27 | 18 | 518µs | 18 | 723µs | foreach my $excluded_role_name ($role1->get_excluded_roles_list) { # spent 723µs making 18 calls to Moose::Meta::Role::get_excluded_roles_list, avg 40µs/call |
| 28 | if ( $role2->does_role($excluded_role_name) ) { | ||||
| 29 | require Moose; | ||||
| 30 | Moose->throw_error("The class " . $role2->name . " does the excluded role '$excluded_role_name'"); | ||||
| 31 | } | ||||
| 32 | $role2->add_excluded_roles($excluded_role_name); | ||||
| 33 | } | ||||
| 34 | } | ||||
| 35 | |||||
| 36 | # spent 15.3ms (1.77+13.6) within Moose::Meta::Role::Application::ToRole::check_required_methods which was called 18 times, avg 853µs/call:
# 18 times (1.77ms+13.6ms) by Moose::Meta::Role::Application::apply at line 51 of Moose/Meta/Role/Application.pm, avg 853µs/call | ||||
| 37 | 18 | 66µs | my ($self, $role1, $role2) = @_; | ||
| 38 | 18 | 459µs | 18 | 786µs | foreach my $required_method ($role1->get_required_method_list) { # spent 786µs making 18 calls to Moose::Meta::Role::get_required_method_list, avg 44µs/call |
| 39 | 22 | 281µs | 22 | 326µs | my $required_method_name = $required_method->name; # spent 326µs making 22 calls to Moose::Meta::Role::Method::Required::name, avg 15µs/call |
| 40 | |||||
| 41 | 22 | 242µs | 22 | 968µs | next if $self->is_aliased_method($required_method_name); # spent 968µs making 22 calls to Moose::Meta::Role::Application::is_aliased_method, avg 44µs/call |
| 42 | |||||
| 43 | 22 | 465µs | 30 | 11.5ms | $role2->add_required_methods($required_method) # spent 10.8ms making 22 calls to Moose::Meta::Role::find_method_by_name, avg 489µs/call
# spent 740µs making 8 calls to Moose::Meta::Role::add_required_methods, avg 92µs/call |
| 44 | unless $role2->find_method_by_name($required_method_name); | ||||
| 45 | } | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | 18 | 198µs | # spent 141µs within Moose::Meta::Role::Application::ToRole::check_required_attributes which was called 18 times, avg 8µs/call:
# 18 times (141µs+0s) by Moose::Meta::Role::Application::apply at line 52 of Moose/Meta/Role/Application.pm, avg 8µs/call | ||
| 49 | |||||
| 50 | } | ||||
| 51 | |||||
| 52 | # spent 5.28ms (1.06+4.23) within Moose::Meta::Role::Application::ToRole::apply_attributes which was called 18 times, avg 293µs/call:
# 18 times (1.06ms+4.23ms) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 293µs/call | ||||
| 53 | 18 | 70µs | my ($self, $role1, $role2) = @_; | ||
| 54 | 18 | 506µs | 18 | 620µs | foreach my $attribute_name ($role1->get_attribute_list) { # spent 620µs making 18 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 34µs/call |
| 55 | # it if it has one already | ||||
| 56 | 6 | 138µs | 6 | 196µs | if ($role2->has_attribute($attribute_name) && # spent 196µs making 6 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 33µ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 | require Moose; | ||||
| 63 | Moose->throw_error( "Role '" | ||||
| 64 | . $role1->name | ||||
| 65 | . "' has encountered an attribute conflict" | ||||
| 66 | . " while being composed into '$role2_name'." | ||||
| 67 | . " This is a fatal error and cannot be disambiguated." | ||||
| 68 | . " The conflicting attribute is named '$attribute_name'." ); | ||||
| 69 | } | ||||
| 70 | else { | ||||
| 71 | 6 | 252µs | 18 | 3.41ms | $role2->add_attribute( # spent 2.38ms making 6 calls to Moose::Meta::Role::add_attribute, avg 397µs/call
# spent 830µs making 6 calls to Moose::Meta::Role::Attribute::clone, avg 138µs/call
# spent 198µs making 6 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 33µs/call |
| 72 | $role1->get_attribute($attribute_name)->clone | ||||
| 73 | ); | ||||
| 74 | } | ||||
| 75 | } | ||||
| 76 | } | ||||
| 77 | |||||
| 78 | # spent 157ms (16.9+140) within Moose::Meta::Role::Application::ToRole::apply_methods which was called 18 times, avg 8.74ms/call:
# 18 times (16.9ms+140ms) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 8.74ms/call | ||||
| 79 | 18 | 65µs | my ( $self, $role1, $role2 ) = @_; | ||
| 80 | 18 | 962µs | 18 | 23.6ms | foreach my $method ( $role1->_get_local_methods ) { # spent 23.5ms making 16 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 1.47ms/call
# spent 102µs making 2 calls to Moose::Meta::Role::Composite::_get_local_methods, avg 51µs/call |
| 81 | |||||
| 82 | 188 | 3.67ms | 188 | 1.09ms | my $method_name = $method->name; # spent 1.09ms making 188 calls to Class::MOP::Method::name, avg 6µs/call |
| 83 | |||||
| 84 | 188 | 4.11ms | 188 | 1.85ms | next if $method->isa('Class::MOP::Method::Meta'); # spent 1.85ms making 188 calls to UNIVERSAL::isa, avg 10µs/call |
| 85 | |||||
| 86 | 172 | 2.22ms | 172 | 8.32ms | unless ( $self->is_method_excluded($method_name) ) { # spent 8.32ms making 172 calls to Moose::Meta::Role::Application::is_method_excluded, avg 48µs/call |
| 87 | |||||
| 88 | 164 | 1.95ms | 164 | 23.7ms | my $role2_method = $role2->get_method($method_name); # spent 23.7ms making 164 calls to Class::MOP::Mixin::HasMethods::get_method, avg 145µs/call |
| 89 | 164 | 720µs | if ( $role2_method | ||
| 90 | && $role2_method->body != $method->body ) { | ||||
| 91 | |||||
| 92 | # method conflicts between roles result in the method becoming | ||||
| 93 | # a requirement | ||||
| 94 | $role2->add_conflicting_method( | ||||
| 95 | name => $method_name, | ||||
| 96 | roles => [ $role1->name, $role2->name ], | ||||
| 97 | ); | ||||
| 98 | } | ||||
| 99 | else { | ||||
| 100 | 164 | 1.87ms | 164 | 75.1ms | $role2->add_method( # spent 75.1ms making 164 calls to Class::MOP::Mixin::HasMethods::add_method, avg 458µs/call |
| 101 | $method_name, | ||||
| 102 | $method, | ||||
| 103 | ); | ||||
| 104 | } | ||||
| 105 | } | ||||
| 106 | |||||
| 107 | 172 | 2.47ms | 172 | 6.65ms | next unless $self->is_method_aliased($method_name); # spent 6.65ms making 172 calls to Moose::Meta::Role::Application::is_method_aliased, avg 39µs/call |
| 108 | |||||
| 109 | my $aliased_method_name = $self->get_method_aliases->{$method_name}; | ||||
| 110 | |||||
| 111 | my $role2_method = $role2->get_method($aliased_method_name); | ||||
| 112 | |||||
| 113 | if ( $role2_method | ||||
| 114 | && $role2_method->body != $method->body ) { | ||||
| 115 | |||||
| 116 | require Moose; | ||||
| 117 | Moose->throw_error( | ||||
| 118 | "Cannot create a method alias if a local method of the same name exists" | ||||
| 119 | ); | ||||
| 120 | } | ||||
| 121 | |||||
| 122 | $role2->add_method( | ||||
| 123 | $aliased_method_name, | ||||
| 124 | $role1->get_method($method_name) | ||||
| 125 | ); | ||||
| 126 | |||||
| 127 | if ( !$role2->has_method($method_name) ) { | ||||
| 128 | $role2->add_required_methods($method_name) | ||||
| 129 | unless $self->is_method_excluded($method_name); | ||||
| 130 | } | ||||
| 131 | } | ||||
| 132 | } | ||||
| 133 | |||||
| 134 | # spent 12.6ms (2.12+10.4) within Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers which was called 18 times, avg 698µs/call:
# 18 times (2.12ms+10.4ms) by Moose::Meta::Role::Application::apply at line 57 of Moose/Meta/Role/Application.pm, avg 698µs/call | ||||
| 135 | 18 | 135µs | my ($self, $role1, $role2) = @_; | ||
| 136 | 18 | 476µs | 18 | 894µs | foreach my $method_name ($role1->get_method_modifier_list('override')) { # spent 894µs making 18 calls to Moose::Meta::Role::get_method_modifier_list, avg 50µs/call |
| 137 | # it if it has one already then ... | ||||
| 138 | 24 | 401µs | 24 | 3.37ms | if ($role2->has_method($method_name)) { # spent 3.37ms making 24 calls to Class::MOP::Mixin::HasMethods::has_method, avg 141µs/call |
| 139 | # if it is being composed into another role | ||||
| 140 | # we have a conflict here, because you cannot | ||||
| 141 | # combine an overridden method with a locally | ||||
| 142 | # defined one | ||||
| 143 | require Moose; | ||||
| 144 | Moose->throw_error("Role '" . $role1->name . "' has encountered an 'override' method conflict " . | ||||
| 145 | "during composition (A local method of the same name as been found). This " . | ||||
| 146 | "is fatal error."); | ||||
| 147 | } | ||||
| 148 | else { | ||||
| 149 | # if we are a role, we need to make sure | ||||
| 150 | # we dont have a conflict with the role | ||||
| 151 | # we are composing into | ||||
| 152 | 24 | 315µs | 24 | 878µs | if ($role2->has_override_method_modifier($method_name) && # spent 878µs making 24 calls to Moose::Meta::Role::has_override_method_modifier, avg 37µs/call |
| 153 | $role2->get_override_method_modifier($method_name) != $role2->get_override_method_modifier($method_name)) { | ||||
| 154 | |||||
| 155 | require Moose; | ||||
| 156 | Moose->throw_error("Role '" . $role1->name . "' has encountered an 'override' method conflict " . | ||||
| 157 | "during composition (Two 'override' methods of the same name encountered). " . | ||||
| 158 | "This is fatal error."); | ||||
| 159 | } | ||||
| 160 | else { | ||||
| 161 | # if there is no conflict, | ||||
| 162 | # just add it to the role | ||||
| 163 | 24 | 469µs | 48 | 5.30ms | $role2->add_override_method_modifier( # spent 4.48ms making 24 calls to Moose::Meta::Role::add_override_method_modifier, avg 187µs/call
# spent 821µs making 24 calls to Moose::Meta::Role::get_override_method_modifier, avg 34µs/call |
| 164 | $method_name, | ||||
| 165 | $role1->get_override_method_modifier($method_name) | ||||
| 166 | ); | ||||
| 167 | } | ||||
| 168 | } | ||||
| 169 | } | ||||
| 170 | } | ||||
| 171 | |||||
| 172 | # spent 8.90ms (2.85+6.06) within Moose::Meta::Role::Application::ToRole::apply_method_modifiers which was called 54 times, avg 165µs/call:
# 18 times (1.37ms+3.72ms) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 74 of Moose/Meta/Role/Application.pm, avg 283µs/call
# 18 times (800µs+1.31ms) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 73 of Moose/Meta/Role/Application.pm, avg 117µs/call
# 18 times (674µs+1.03ms) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 75 of Moose/Meta/Role/Application.pm, avg 94µs/call | ||||
| 173 | 54 | 210µs | my ($self, $modifier_type, $role1, $role2) = @_; | ||
| 174 | 54 | 196µs | my $add = "add_${modifier_type}_method_modifier"; | ||
| 175 | 54 | 149µs | my $get = "get_${modifier_type}_method_modifiers"; | ||
| 176 | 54 | 1.19ms | 54 | 2.26ms | foreach my $method_name ($role1->get_method_modifier_list($modifier_type)) { # spent 2.26ms making 54 calls to Moose::Meta::Role::get_method_modifier_list, avg 42µs/call |
| 177 | $role2->$add( | ||||
| 178 | $method_name, | ||||
| 179 | $_ | ||||
| 180 | 54 | 939µs | 54 | 3.80ms | ) foreach $role1->$get($method_name); # spent 2.07ms making 21 calls to Moose::Meta::Role::add_around_method_modifier, avg 99µs/call
# spent 878µs making 21 calls to Moose::Meta::Role::get_around_method_modifiers, avg 42µs/call
# spent 390µs making 4 calls to Moose::Meta::Role::add_before_method_modifier, avg 98µs/call
# spent 198µs making 2 calls to Moose::Meta::Role::add_after_method_modifier, avg 99µs/call
# spent 171µs making 4 calls to Moose::Meta::Role::get_before_method_modifiers, avg 43µs/call
# spent 91µs making 2 calls to Moose::Meta::Role::get_after_method_modifiers, avg 45µs/call |
| 181 | } | ||||
| 182 | } | ||||
| 183 | |||||
| 184 | |||||
| 185 | 1 | 12µs | 1; | ||
| 186 | |||||
| 187 | __END__ |