| Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role/Application/ToRole.pm |
| Statements | Executed 2003 statements in 3.31ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 11 | 1 | 1 | 2.40ms | 35.7ms | Moose::Meta::Role::Application::ToRole::apply_methods |
| 11 | 1 | 1 | 272µs | 1.54ms | Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers |
| 33 | 3 | 1 | 269µs | 820µs | Moose::Meta::Role::Application::ToRole::apply_method_modifiers |
| 11 | 1 | 1 | 181µs | 1.48ms | Moose::Meta::Role::Application::ToRole::check_required_methods |
| 11 | 1 | 1 | 84µs | 187µs | Moose::Meta::Role::Application::ToRole::check_role_exclusions |
| 11 | 1 | 1 | 60µs | 40.5ms | Moose::Meta::Role::Application::ToRole::apply |
| 11 | 1 | 1 | 59µs | 226µs | Moose::Meta::Role::Application::ToRole::apply_attributes |
| 1 | 1 | 1 | 9µs | 9µs | Moose::Meta::Role::Application::ToRole::BEGIN@2 |
| 11 | 1 | 1 | 8µs | 8µs | Moose::Meta::Role::Application::ToRole::check_required_attributes |
| 1 | 1 | 1 | 6µs | 27µs | Moose::Meta::Role::Application::ToRole::BEGIN@13 |
| 1 | 1 | 1 | 6µs | 9µs | Moose::Meta::Role::Application::ToRole::BEGIN@10 |
| 1 | 1 | 1 | 6µs | 16µs | Moose::Meta::Role::Application::ToRole::BEGIN@9 |
| 1 | 1 | 1 | 6µs | 331µs | Moose::Meta::Role::Application::ToRole::BEGIN@11 |
| 1 | 1 | 1 | 6µs | 53µs | Moose::Meta::Role::Application::ToRole::BEGIN@15 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Role::Application::ToRole; | ||||
| 2 | # spent 9µs within Moose::Meta::Role::Application::ToRole::BEGIN@2 which was called:
# once (9µs+0s) by Moose::BEGIN@40 at line 4 | ||||
| 3 | 1 | 4µs | $Moose::Meta::Role::Application::ToRole::AUTHORITY = 'cpan:STEVAN'; | ||
| 4 | 1 | 33µs | 1 | 9µs | } # spent 9µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@2 |
| 5 | { | ||||
| 6 | 2 | 900ns | $Moose::Meta::Role::Application::ToRole::VERSION = '2.1005'; | ||
| 7 | } | ||||
| 8 | |||||
| 9 | 2 | 20µs | 2 | 27µs | # spent 16µs (6+10) within Moose::Meta::Role::Application::ToRole::BEGIN@9 which was called:
# once (6µs+10µs) by Moose::BEGIN@40 at line 9 # spent 16µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@9
# spent 10µs making 1 call to strict::import |
| 10 | 2 | 22µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::Role::Application::ToRole::BEGIN@10 which was called:
# once (6µs+3µs) by Moose::BEGIN@40 at line 10 # spent 9µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@10
# spent 3µs making 1 call to warnings::import |
| 11 | 2 | 25µs | 2 | 657µs | # spent 331µs (6+326) within Moose::Meta::Role::Application::ToRole::BEGIN@11 which was called:
# once (6µs+326µs) by Moose::BEGIN@40 at line 11 # spent 331µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@11
# spent 326µs making 1 call to metaclass::import |
| 12 | |||||
| 13 | 2 | 22µs | 2 | 47µs | # spent 27µs (6+20) within Moose::Meta::Role::Application::ToRole::BEGIN@13 which was called:
# once (6µs+20µs) by Moose::BEGIN@40 at line 13 # spent 27µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@13
# spent 20µs making 1 call to Exporter::import |
| 14 | |||||
| 15 | 2 | 633µs | 2 | 101µs | # spent 53µs (6+48) within Moose::Meta::Role::Application::ToRole::BEGIN@15 which was called:
# once (6µs+48µs) by Moose::BEGIN@40 at line 15 # spent 53µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@15
# spent 48µs making 1 call to base::import |
| 16 | |||||
| 17 | # spent 40.5ms (60µs+40.4) within Moose::Meta::Role::Application::ToRole::apply which was called 11 times, avg 3.68ms/call:
# 11 times (60µs+40.4ms) by Moose::Meta::Role::apply at line 470 of Moose/Meta/Role.pm, avg 3.68ms/call | ||||
| 18 | 11 | 3µs | my ($self, $role1, $role2) = @_; | ||
| 19 | 11 | 17µs | 11 | 3.48ms | $self->SUPER::apply($role1, $role2); # spent 40.3ms making 11 calls to Moose::Meta::Role::Application::apply, avg 3.66ms/call, recursion: max depth 1, sum of overlapping time 36.8ms |
| 20 | 11 | 25µs | 11 | 131µs | $role2->add_role($role1); # spent 131µs making 11 calls to Moose::Meta::Role::add_role, avg 12µs/call |
| 21 | } | ||||
| 22 | |||||
| 23 | # spent 187µs (84+103) within Moose::Meta::Role::Application::ToRole::check_role_exclusions which was called 11 times, avg 17µs/call:
# 11 times (84µs+103µs) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 17µs/call | ||||
| 24 | 11 | 2µs | my ($self, $role1, $role2) = @_; | ||
| 25 | 11 | 34µs | 22 | 62µs | if ( $role2->excludes_role($role1->name) ) { # spent 54µs making 11 calls to Moose::Meta::Role::excludes_role, avg 5µs/call
# spent 6µs making 9 calls to Class::MOP::Package::name, avg 644ns/call
# spent 2µs making 2 calls to Moose::Meta::Role::Composite::name, avg 1µs/call |
| 26 | require Moose; | ||||
| 27 | Moose->throw_error("Conflict detected: " . $role2->name . " excludes role '" . $role1->name . "'"); | ||||
| 28 | } | ||||
| 29 | 11 | 34µs | 11 | 41µs | foreach my $excluded_role_name ($role1->get_excluded_roles_list) { # spent 41µs making 11 calls to Moose::Meta::Role::get_excluded_roles_list, avg 4µs/call |
| 30 | if ( $role2->does_role($excluded_role_name) ) { | ||||
| 31 | require Moose; | ||||
| 32 | Moose->throw_error("The role " . $role2->name . " does the excluded role '$excluded_role_name'"); | ||||
| 33 | } | ||||
| 34 | $role2->add_excluded_roles($excluded_role_name); | ||||
| 35 | } | ||||
| 36 | } | ||||
| 37 | |||||
| 38 | # spent 1.48ms (181µs+1.30) within Moose::Meta::Role::Application::ToRole::check_required_methods which was called 11 times, avg 134µs/call:
# 11 times (181µs+1.30ms) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 134µs/call | ||||
| 39 | 11 | 3µs | my ($self, $role1, $role2) = @_; | ||
| 40 | 11 | 30µs | 11 | 47µs | foreach my $required_method ($role1->get_required_method_list) { # spent 47µs making 11 calls to Moose::Meta::Role::get_required_method_list, avg 4µs/call |
| 41 | 20 | 22µs | 20 | 28µs | my $required_method_name = $required_method->name; # spent 28µs making 20 calls to Moose::Meta::Role::Method::Required::name, avg 1µs/call |
| 42 | |||||
| 43 | 20 | 19µs | 20 | 96µs | next if $self->is_aliased_method($required_method_name); # spent 96µs making 20 calls to Moose::Meta::Role::Application::is_aliased_method, avg 5µs/call |
| 44 | |||||
| 45 | 20 | 38µs | 27 | 1.13ms | $role2->add_required_methods($required_method) # spent 1.05ms making 20 calls to Moose::Meta::Role::find_method_by_name, avg 53µs/call
# spent 73µs making 7 calls to Moose::Meta::Role::add_required_methods, avg 10µs/call |
| 46 | unless $role2->find_method_by_name($required_method_name); | ||||
| 47 | } | ||||
| 48 | } | ||||
| 49 | |||||
| 50 | 11 | 16µs | # spent 8µs within Moose::Meta::Role::Application::ToRole::check_required_attributes which was called 11 times, avg 718ns/call:
# 11 times (8µs+0s) by Moose::Meta::Role::Application::apply at line 56 of Moose/Meta/Role/Application.pm, avg 718ns/call | ||
| 51 | |||||
| 52 | } | ||||
| 53 | |||||
| 54 | # spent 226µs (59+167) within Moose::Meta::Role::Application::ToRole::apply_attributes which was called 11 times, avg 21µs/call:
# 11 times (59µs+167µs) by Moose::Meta::Role::Application::apply at line 58 of Moose/Meta/Role/Application.pm, avg 21µs/call | ||||
| 55 | 11 | 4µs | my ($self, $role1, $role2) = @_; | ||
| 56 | 11 | 31µs | 11 | 36µs | foreach my $attribute_name ($role1->get_attribute_list) { # spent 36µs making 11 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 3µs/call |
| 57 | # it if it has one already | ||||
| 58 | 2 | 4µs | 2 | 7µs | if ($role2->has_attribute($attribute_name) && # spent 7µs making 2 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 3µs/call |
| 59 | # make sure we haven't seen this one already too | ||||
| 60 | $role2->get_attribute($attribute_name) != $role1->get_attribute($attribute_name)) { | ||||
| 61 | |||||
| 62 | my $role2_name = $role2->name; | ||||
| 63 | |||||
| 64 | require Moose; | ||||
| 65 | Moose->throw_error( "Role '" | ||||
| 66 | . $role1->name | ||||
| 67 | . "' has encountered an attribute conflict" | ||||
| 68 | . " while being composed into '$role2_name'." | ||||
| 69 | . " This is a fatal error and cannot be disambiguated." | ||||
| 70 | . " The conflicting attribute is named '$attribute_name'." ); | ||||
| 71 | } | ||||
| 72 | else { | ||||
| 73 | 2 | 5µs | 6 | 124µs | $role2->add_attribute( # spent 75µs making 2 calls to Moose::Meta::Role::add_attribute, avg 38µs/call
# spent 43µs making 2 calls to Moose::Meta::Role::Attribute::clone, avg 21µs/call
# spent 6µs making 2 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 3µs/call |
| 74 | $role1->get_attribute($attribute_name)->clone | ||||
| 75 | ); | ||||
| 76 | } | ||||
| 77 | } | ||||
| 78 | } | ||||
| 79 | |||||
| 80 | # spent 35.7ms (2.40+33.3) within Moose::Meta::Role::Application::ToRole::apply_methods which was called 11 times, avg 3.25ms/call:
# 11 times (2.40ms+33.3ms) by Moose::Meta::Role::Application::apply at line 59 of Moose/Meta/Role/Application.pm, avg 3.25ms/call | ||||
| 81 | 11 | 2µs | my ( $self, $role1, $role2 ) = @_; | ||
| 82 | 11 | 57µs | 11 | 5.67ms | foreach my $method ( $role1->_get_local_methods ) { # spent 5.66ms making 9 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 629µs/call
# spent 13µs making 2 calls to Moose::Meta::Role::Composite::_get_local_methods, avg 6µs/call |
| 83 | |||||
| 84 | 225 | 492µs | 225 | 123µs | my $method_name = $method->name; # spent 123µs making 225 calls to Class::MOP::Method::name, avg 545ns/call |
| 85 | |||||
| 86 | 225 | 531µs | 225 | 236µs | next if $method->isa('Class::MOP::Method::Meta'); # spent 236µs making 225 calls to UNIVERSAL::isa, avg 1µs/call |
| 87 | |||||
| 88 | 216 | 166µs | 216 | 887µs | unless ( $self->is_method_excluded($method_name) ) { # spent 887µs making 216 calls to Moose::Meta::Role::Application::is_method_excluded, avg 4µs/call |
| 89 | |||||
| 90 | 216 | 160µs | 216 | 8.11ms | my $role2_method = $role2->get_method($method_name); # spent 8.11ms making 216 calls to Class::MOP::Mixin::HasMethods::get_method, avg 38µs/call |
| 91 | 216 | 138µs | 44 | 22µs | if ( $role2_method # spent 22µs making 44 calls to Class::MOP::Method::body, avg 491ns/call |
| 92 | && $role2_method->body != $method->body ) { | ||||
| 93 | |||||
| 94 | # method conflicts between roles used to result in the method | ||||
| 95 | # becoming a requirement but now are permitted just like | ||||
| 96 | # for classes, hence no code in this branch anymore. | ||||
| 97 | } | ||||
| 98 | else { | ||||
| 99 | 194 | 146µs | 194 | 17.4ms | $role2->add_method( # spent 17.4ms making 194 calls to Class::MOP::Mixin::HasMethods::add_method, avg 90µs/call |
| 100 | $method_name, | ||||
| 101 | $method, | ||||
| 102 | ); | ||||
| 103 | } | ||||
| 104 | } | ||||
| 105 | |||||
| 106 | 216 | 243µs | 216 | 830µs | next unless $self->is_method_aliased($method_name); # spent 830µs making 216 calls to Moose::Meta::Role::Application::is_method_aliased, avg 4µs/call |
| 107 | |||||
| 108 | my $aliased_method_name = $self->get_method_aliases->{$method_name}; | ||||
| 109 | |||||
| 110 | my $role2_method = $role2->get_method($aliased_method_name); | ||||
| 111 | |||||
| 112 | if ( $role2_method | ||||
| 113 | && $role2_method->body != $method->body ) { | ||||
| 114 | |||||
| 115 | require Moose; | ||||
| 116 | Moose->throw_error( | ||||
| 117 | "Cannot create a method alias if a local method of the same name exists" | ||||
| 118 | ); | ||||
| 119 | } | ||||
| 120 | |||||
| 121 | $role2->add_method( | ||||
| 122 | $aliased_method_name, | ||||
| 123 | $role1->get_method($method_name) | ||||
| 124 | ); | ||||
| 125 | |||||
| 126 | if ( !$role2->has_method($method_name) ) { | ||||
| 127 | $role2->add_required_methods($method_name) | ||||
| 128 | unless $self->is_method_excluded($method_name); | ||||
| 129 | } | ||||
| 130 | } | ||||
| 131 | } | ||||
| 132 | |||||
| 133 | # spent 1.54ms (272µs+1.26) within Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers which was called 11 times, avg 140µs/call:
# 11 times (272µs+1.26ms) by Moose::Meta::Role::Application::apply at line 61 of Moose/Meta/Role/Application.pm, avg 140µs/call | ||||
| 134 | 11 | 3µs | my ($self, $role1, $role2) = @_; | ||
| 135 | 11 | 36µs | 11 | 58µs | foreach my $method_name ($role1->get_method_modifier_list('override')) { # spent 58µs making 11 calls to Moose::Meta::Role::get_method_modifier_list, avg 5µs/call |
| 136 | # it if it has one already then ... | ||||
| 137 | 30 | 35µs | 30 | 438µs | if ($role2->has_method($method_name)) { # spent 438µs making 30 calls to Class::MOP::Mixin::HasMethods::has_method, avg 15µs/call |
| 138 | # if it is being composed into another role | ||||
| 139 | # we have a conflict here, because you cannot | ||||
| 140 | # combine an overridden method with a locally | ||||
| 141 | # defined one | ||||
| 142 | require Moose; | ||||
| 143 | Moose->throw_error("Role '" . $role1->name . "' has encountered an 'override' method conflict " . | ||||
| 144 | "during composition (A local method of the same name as been found). This " . | ||||
| 145 | "is fatal error."); | ||||
| 146 | } | ||||
| 147 | else { | ||||
| 148 | # if we are a role, we need to make sure | ||||
| 149 | # we don't have a conflict with the role | ||||
| 150 | # we are composing into | ||||
| 151 | 30 | 28µs | 30 | 108µs | if ($role2->has_override_method_modifier($method_name) && # spent 108µs making 30 calls to Moose::Meta::Role::has_override_method_modifier, avg 4µs/call |
| 152 | $role2->get_override_method_modifier($method_name) != $role2->get_override_method_modifier($method_name)) { | ||||
| 153 | |||||
| 154 | require Moose; | ||||
| 155 | Moose->throw_error("Role '" . $role1->name . "' has encountered an 'override' method conflict " . | ||||
| 156 | "during composition (Two 'override' methods of the same name encountered). " . | ||||
| 157 | "This is fatal error."); | ||||
| 158 | } | ||||
| 159 | else { | ||||
| 160 | # if there is no conflict, | ||||
| 161 | # just add it to the role | ||||
| 162 | 30 | 44µs | 60 | 660µs | $role2->add_override_method_modifier( # spent 568µs making 30 calls to Moose::Meta::Role::add_override_method_modifier, avg 19µs/call
# spent 92µs making 30 calls to Moose::Meta::Role::get_override_method_modifier, avg 3µs/call |
| 163 | $method_name, | ||||
| 164 | $role1->get_override_method_modifier($method_name) | ||||
| 165 | ); | ||||
| 166 | } | ||||
| 167 | } | ||||
| 168 | } | ||||
| 169 | } | ||||
| 170 | |||||
| 171 | # spent 820µs (269+551) within Moose::Meta::Role::Application::ToRole::apply_method_modifiers which was called 33 times, avg 25µs/call:
# 11 times (166µs+410µs) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 78 of Moose/Meta/Role/Application.pm, avg 52µs/call
# 11 times (60µs+81µs) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 77 of Moose/Meta/Role/Application.pm, avg 13µs/call
# 11 times (43µs+60µs) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 79 of Moose/Meta/Role/Application.pm, avg 9µs/call | ||||
| 172 | 33 | 9µs | my ($self, $modifier_type, $role1, $role2) = @_; | ||
| 173 | 33 | 10µs | my $add = "add_${modifier_type}_method_modifier"; | ||
| 174 | 33 | 5µs | my $get = "get_${modifier_type}_method_modifiers"; | ||
| 175 | 33 | 82µs | 33 | 141µs | foreach my $method_name ($role1->get_method_modifier_list($modifier_type)) { # spent 141µs making 33 calls to Moose::Meta::Role::get_method_modifier_list, avg 4µs/call |
| 176 | $role2->$add( | ||||
| 177 | $method_name, | ||||
| 178 | $_ | ||||
| 179 | 30 | 83µs | 60 | 410µs | ) foreach $role1->$get($method_name); # spent 252µs making 27 calls to Moose::Meta::Role::add_around_method_modifier, avg 9µs/call
# spent 111µs making 27 calls to Moose::Meta::Role::get_around_method_modifiers, avg 4µs/call
# spent 20µs making 2 calls to Moose::Meta::Role::add_before_method_modifier, avg 10µs/call
# spent 12µs making 2 calls to Moose::Meta::Role::get_before_method_modifiers, avg 6µs/call
# spent 10µs making 1 call to Moose::Meta::Role::add_after_method_modifier
# spent 5µs making 1 call to Moose::Meta::Role::get_after_method_modifiers |
| 180 | } | ||||
| 181 | } | ||||
| 182 | |||||
| 183 | |||||
| 184 | 1 | 2µs | 1; | ||
| 185 | |||||
| 186 | # ABSTRACT: Compose a role into another role | ||||
| 187 | |||||
| 188 | __END__ |