| Filename | /home/doy/coding/src/Moose/blib/lib//Moose/Meta/Role/Application/ToClass.pm |
| Statements | Executed 7765 statements in 110ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 73 | 1 | 1 | 66.7ms | 642ms | Moose::Meta::Role::Application::ToClass::apply_methods |
| 219 | 3 | 1 | 10.4ms | 135ms | Moose::Meta::Role::Application::ToClass::apply_method_modifiers |
| 73 | 1 | 1 | 6.97ms | 1.21s | Moose::Meta::Role::Application::ToClass::apply |
| 73 | 1 | 1 | 5.10ms | 198ms | Moose::Meta::Role::Application::ToClass::apply_attributes |
| 73 | 1 | 1 | 4.69ms | 66.3ms | Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers |
| 73 | 1 | 1 | 4.25ms | 121ms | Moose::Meta::Role::Application::ToClass::check_role_exclusions |
| 73 | 1 | 1 | 3.24ms | 13.1ms | Moose::Meta::Role::Application::ToClass::check_required_methods |
| 73 | 1 | 1 | 535µs | 535µs | Moose::Meta::Role::Application::ToClass::check_required_attributes |
| 1 | 1 | 1 | 70µs | 88µs | Moose::Meta::Role::Application::ToClass::BEGIN@3 |
| 1 | 1 | 1 | 43µs | 331µs | Moose::Meta::Role::Application::ToClass::BEGIN@14 |
| 1 | 1 | 1 | 42µs | 916µs | Moose::Meta::Role::Application::ToClass::BEGIN@7 |
| 1 | 1 | 1 | 42µs | 234µs | Moose::Meta::Role::Application::ToClass::BEGIN@8 |
| 1 | 1 | 1 | 40µs | 2.74ms | Moose::Meta::Role::Application::ToClass::BEGIN@5 |
| 1 | 1 | 1 | 40µs | 107µs | Moose::Meta::Role::Application::ToClass::BEGIN@4 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Role::Application::ToClass; | ||||
| 2 | |||||
| 3 | 3 | 102µs | 2 | 106µs | # spent 88µs (70+18) within Moose::Meta::Role::Application::ToClass::BEGIN@3 which was called:
# once (70µs+18µs) by Moose::BEGIN@31 at line 3 # spent 88µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@3
# spent 18µs making 1 call to strict::import |
| 4 | 3 | 96µs | 2 | 174µs | # spent 107µs (40+67) within Moose::Meta::Role::Application::ToClass::BEGIN@4 which was called:
# once (40µs+67µs) by Moose::BEGIN@31 at line 4 # spent 107µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@4
# spent 67µs making 1 call to warnings::import |
| 5 | 3 | 144µs | 2 | 5.43ms | # spent 2.74ms (40µs+2.70) within Moose::Meta::Role::Application::ToClass::BEGIN@5 which was called:
# once (40µs+2.70ms) by Moose::BEGIN@31 at line 5 # spent 2.74ms making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@5
# spent 2.70ms making 1 call to metaclass::import |
| 6 | |||||
| 7 | 3 | 166µs | 2 | 1.79ms | # spent 916µs (42+874) within Moose::Meta::Role::Application::ToClass::BEGIN@7 which was called:
# once (42µs+874µs) by Moose::BEGIN@31 at line 7 # spent 916µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@7
# spent 874µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756] |
| 8 | 3 | 259µs | 2 | 426µs | # spent 234µs (42+192) within Moose::Meta::Role::Application::ToClass::BEGIN@8 which was called:
# once (42µs+192µs) by Moose::BEGIN@31 at line 8 # spent 234µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@8
# spent 192µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 1 | 5µs | our $VERSION = '1.19'; | ||
| 11 | 1 | 61µs | $VERSION = eval $VERSION; # spent 12µs executing statements in string eval | ||
| 12 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 13 | |||||
| 14 | 3 | 3.06ms | 2 | 620µs | # spent 331µs (43+288) within Moose::Meta::Role::Application::ToClass::BEGIN@14 which was called:
# once (43µs+288µs) by Moose::BEGIN@31 at line 14 # spent 331µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@14
# spent 288µs making 1 call to base::import |
| 15 | |||||
| 16 | 1 | 28µs | 2 | 2.15ms | __PACKAGE__->meta->add_attribute('role' => ( # spent 2.03ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 120µs making 1 call to Moose::Meta::Role::Application::ToClass::meta |
| 17 | reader => 'role', | ||||
| 18 | )); | ||||
| 19 | |||||
| 20 | 1 | 23µs | 2 | 1.99ms | __PACKAGE__->meta->add_attribute('class' => ( # spent 1.90ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 89µs making 1 call to Moose::Meta::Role::Application::ToClass::meta |
| 21 | reader => 'class', | ||||
| 22 | )); | ||||
| 23 | |||||
| 24 | # spent 1.21s (6.97ms+1.20) within Moose::Meta::Role::Application::ToClass::apply which was called 73 times, avg 16.6ms/call:
# 73 times (6.97ms+1.20s) by Moose::Meta::Role::apply at line 483 of Moose/Meta/Role.pm, avg 16.6ms/call | ||||
| 25 | 73 | 282µs | my ($self, $role, $class) = @_; | ||
| 26 | |||||
| 27 | # We need weak_ref in CMOP :( | ||||
| 28 | 73 | 1.45ms | 73 | 487µs | weaken($self->{role} = $role); # spent 487µs making 73 calls to Scalar::Util::weaken, avg 7µs/call |
| 29 | 73 | 1.42ms | 73 | 407µs | weaken($self->{class} = $class); # spent 407µs making 73 calls to Scalar::Util::weaken, avg 6µs/call |
| 30 | |||||
| 31 | 73 | 2.08ms | 73 | 1.19s | $self->SUPER::apply($role, $class); # spent 1.19s making 73 calls to Moose::Meta::Role::Application::apply, avg 16.3ms/call |
| 32 | |||||
| 33 | 73 | 983µs | 73 | 6.22ms | $class->add_role($role); # spent 6.22ms making 73 calls to Moose::Meta::Class::add_role, avg 85µs/call |
| 34 | 73 | 1.56ms | 73 | 5.31ms | $class->add_role_application($self); # spent 5.31ms making 73 calls to Moose::Meta::Class::add_role_application, avg 73µs/call |
| 35 | } | ||||
| 36 | |||||
| 37 | # spent 121ms (4.25+116) within Moose::Meta::Role::Application::ToClass::check_role_exclusions which was called 73 times, avg 1.65ms/call:
# 73 times (4.25ms+116ms) by Moose::Meta::Role::Application::apply at line 50 of Moose/Meta/Role/Application.pm, avg 1.65ms/call | ||||
| 38 | 73 | 281µs | my ($self, $role, $class) = @_; | ||
| 39 | 73 | 2.28ms | 146 | 113ms | if ($class->excludes_role($role->name)) { # spent 113ms making 73 calls to Moose::Meta::Class::excludes_role, avg 1.55ms/call
# spent 455µs making 73 calls to Class::MOP::Package::name, avg 6µs/call |
| 40 | $class->throw_error("Conflict detected: " . $class->name . " excludes role '" . $role->name . "'"); | ||||
| 41 | } | ||||
| 42 | 73 | 2.04ms | 73 | 3.04ms | foreach my $excluded_role_name ($role->get_excluded_roles_list) { # spent 3.04ms making 73 calls to Moose::Meta::Role::get_excluded_roles_list, avg 42µs/call |
| 43 | if ($class->does_role($excluded_role_name)) { | ||||
| 44 | $class->throw_error("The class " . $class->name . " does the excluded role '$excluded_role_name'"); | ||||
| 45 | } | ||||
| 46 | } | ||||
| 47 | } | ||||
| 48 | |||||
| 49 | # spent 13.1ms (3.24+9.90) within Moose::Meta::Role::Application::ToClass::check_required_methods which was called 73 times, avg 180µs/call:
# 73 times (3.24ms+9.90ms) by Moose::Meta::Role::Application::apply at line 51 of Moose/Meta/Role/Application.pm, avg 180µs/call | ||||
| 50 | 73 | 253µs | my ($self, $role, $class) = @_; | ||
| 51 | |||||
| 52 | 73 | 140µs | my @missing; | ||
| 53 | 73 | 121µs | my @is_attr; | ||
| 54 | |||||
| 55 | # NOTE: | ||||
| 56 | # we might need to move this down below the | ||||
| 57 | # the attributes so that we can require any | ||||
| 58 | # attribute accessors. However I am thinking | ||||
| 59 | # that maybe those are somehow exempt from | ||||
| 60 | # the require methods stuff. | ||||
| 61 | 73 | 1.18ms | 73 | 2.90ms | foreach my $required_method ($role->get_required_method_list) { # spent 2.90ms making 73 calls to Moose::Meta::Role::get_required_method_list, avg 40µs/call |
| 62 | 13 | 187µs | 13 | 208µs | my $required_method_name = $required_method->name; # spent 208µs making 13 calls to Moose::Meta::Role::Method::Required::name, avg 16µs/call |
| 63 | |||||
| 64 | 13 | 265µs | 13 | 6.78ms | if (!$class->find_method_by_name($required_method_name)) { # spent 6.78ms making 13 calls to Class::MOP::Class::find_method_by_name, avg 522µs/call |
| 65 | |||||
| 66 | next if $self->is_aliased_method($required_method_name); | ||||
| 67 | |||||
| 68 | push @missing, $required_method; | ||||
| 69 | } | ||||
| 70 | } | ||||
| 71 | |||||
| 72 | 73 | 878µs | return unless @missing; | ||
| 73 | |||||
| 74 | my $error = ''; | ||||
| 75 | |||||
| 76 | @missing = sort { $a->name cmp $b->name } @missing; | ||||
| 77 | my @conflicts = grep { $_->isa('Moose::Meta::Role::Method::Conflicting') } @missing; | ||||
| 78 | |||||
| 79 | if (@conflicts) { | ||||
| 80 | my $conflict = $conflicts[0]; | ||||
| 81 | my $roles = $conflict->roles_as_english_list; | ||||
| 82 | |||||
| 83 | my @same_role_conflicts = grep { $_->roles_as_english_list eq $roles } @conflicts; | ||||
| 84 | |||||
| 85 | if (@same_role_conflicts == 1) { | ||||
| 86 | $error | ||||
| 87 | .= "Due to a method name conflict in roles " | ||||
| 88 | . $roles | ||||
| 89 | . ", the method '" | ||||
| 90 | . $conflict->name | ||||
| 91 | . "' must be implemented or excluded by '" | ||||
| 92 | . $class->name | ||||
| 93 | . q{'}; | ||||
| 94 | } | ||||
| 95 | else { | ||||
| 96 | my $methods | ||||
| 97 | = Moose::Util::english_list( map { q{'} . $_->name . q{'} } @same_role_conflicts ); | ||||
| 98 | |||||
| 99 | $error | ||||
| 100 | .= "Due to method name conflicts in roles " | ||||
| 101 | . $roles | ||||
| 102 | . ", the methods " | ||||
| 103 | . $methods | ||||
| 104 | . " must be implemented or excluded by '" | ||||
| 105 | . $class->name | ||||
| 106 | . q{'}; | ||||
| 107 | } | ||||
| 108 | } | ||||
| 109 | elsif (@missing) { | ||||
| 110 | my $noun = @missing == 1 ? 'method' : 'methods'; | ||||
| 111 | |||||
| 112 | my $list | ||||
| 113 | = Moose::Util::english_list( map { q{'} . $_ . q{'} } @missing ); | ||||
| 114 | |||||
| 115 | $error | ||||
| 116 | .= q{'} | ||||
| 117 | . $role->name | ||||
| 118 | . "' requires the $noun $list " | ||||
| 119 | . "to be implemented by '" | ||||
| 120 | . $class->name . q{'}; | ||||
| 121 | } | ||||
| 122 | |||||
| 123 | $class->throw_error($error); | ||||
| 124 | } | ||||
| 125 | |||||
| 126 | 73 | 717µs | # spent 535µs within Moose::Meta::Role::Application::ToClass::check_required_attributes which was called 73 times, avg 7µs/call:
# 73 times (535µs+0s) by Moose::Meta::Role::Application::apply at line 52 of Moose/Meta/Role/Application.pm, avg 7µs/call | ||
| 127 | |||||
| 128 | } | ||||
| 129 | |||||
| 130 | # spent 198ms (5.10+193) within Moose::Meta::Role::Application::ToClass::apply_attributes which was called 73 times, avg 2.71ms/call:
# 73 times (5.10ms+193ms) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 2.71ms/call | ||||
| 131 | 73 | 250µs | my ($self, $role, $class) = @_; | ||
| 132 | 73 | 908µs | 73 | 1.03ms | my $attr_metaclass = $role->applied_attribute_metaclass; # spent 1.03ms making 73 calls to Moose::Meta::Role::applied_attribute_metaclass, avg 14µs/call |
| 133 | |||||
| 134 | 73 | 1.97ms | 73 | 2.46ms | foreach my $attribute_name ($role->get_attribute_list) { # spent 2.46ms making 73 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 34µs/call |
| 135 | # it if it has one already | ||||
| 136 | 21 | 725µs | 21 | 741µs | if ($class->has_attribute($attribute_name) && # spent 741µs making 21 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 35µs/call |
| 137 | # make sure we haven't seen this one already too | ||||
| 138 | $class->get_attribute($attribute_name) != $role->get_attribute($attribute_name)) { | ||||
| 139 | next; | ||||
| 140 | } | ||||
| 141 | else { | ||||
| 142 | 21 | 769µs | 63 | 114ms | $class->add_attribute( # spent 144ms making 21 calls to Moose::Meta::Class::add_attribute, avg 6.85ms/call, recursion: max depth 1, sum of overlapping time 74.8ms
# spent 43.8ms making 21 calls to Moose::Meta::Role::Attribute::attribute_for_class, avg 2.09ms/call
# spent 694µs making 21 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 33µs/call |
| 143 | $role->get_attribute($attribute_name)->attribute_for_class($attr_metaclass) | ||||
| 144 | ); | ||||
| 145 | } | ||||
| 146 | } | ||||
| 147 | } | ||||
| 148 | |||||
| 149 | # spent 642ms (66.7+575) within Moose::Meta::Role::Application::ToClass::apply_methods which was called 73 times, avg 8.79ms/call:
# 73 times (66.7ms+575ms) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 8.79ms/call | ||||
| 150 | 73 | 256µs | my ( $self, $role, $class ) = @_; | ||
| 151 | |||||
| 152 | 73 | 3.24ms | 73 | 103ms | foreach my $method ( $role->_get_local_methods ) { # spent 103ms making 73 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 1.41ms/call |
| 153 | 745 | 14.5ms | 745 | 4.27ms | my $method_name = $method->name; # spent 4.27ms making 745 calls to Class::MOP::Method::name, avg 6µs/call |
| 154 | |||||
| 155 | 745 | 16.5ms | 745 | 7.71ms | next if $method->isa('Class::MOP::Method::Meta'); # spent 7.71ms making 745 calls to UNIVERSAL::isa, avg 10µs/call |
| 156 | |||||
| 157 | 672 | 8.88ms | 672 | 29.9ms | unless ( $self->is_method_excluded($method_name) ) { # spent 29.9ms making 672 calls to Moose::Meta::Role::Application::is_method_excluded, avg 45µs/call |
| 158 | |||||
| 159 | 672 | 7.54ms | 672 | 99.3ms | my $class_method = $class->get_method($method_name); # spent 99.3ms making 672 calls to Class::MOP::Mixin::HasMethods::get_method, avg 148µs/call |
| 160 | |||||
| 161 | 672 | 1.26ms | next if $class_method && $class_method->body != $method->body; | ||
| 162 | |||||
| 163 | 672 | 8.05ms | 672 | 302ms | $class->add_method( # spent 302ms making 672 calls to Class::MOP::Mixin::HasMethods::add_method, avg 450µs/call |
| 164 | $method_name, | ||||
| 165 | $method, | ||||
| 166 | ); | ||||
| 167 | } | ||||
| 168 | |||||
| 169 | 672 | 9.15ms | 672 | 27.3ms | next unless $self->is_method_aliased($method_name); # spent 27.3ms making 672 calls to Moose::Meta::Role::Application::is_method_aliased, avg 41µs/call |
| 170 | |||||
| 171 | my $aliased_method_name = $self->get_method_aliases->{$method_name}; | ||||
| 172 | |||||
| 173 | my $class_method = $class->get_method($aliased_method_name); | ||||
| 174 | |||||
| 175 | if ( $class_method && $class_method->body != $method->body ) { | ||||
| 176 | $class->throw_error( | ||||
| 177 | "Cannot create a method alias if a local method of the same name exists" | ||||
| 178 | ); | ||||
| 179 | } | ||||
| 180 | |||||
| 181 | $class->add_method( | ||||
| 182 | $aliased_method_name, | ||||
| 183 | $method, | ||||
| 184 | ); | ||||
| 185 | } | ||||
| 186 | |||||
| 187 | # we must reset the cache here since | ||||
| 188 | # we are just aliasing methods, otherwise | ||||
| 189 | # the modifiers go wonky. | ||||
| 190 | 73 | 1.55ms | 73 | 778µs | $class->reset_package_cache_flag; # spent 778µs making 73 calls to Class::MOP::Mixin::HasMethods::reset_package_cache_flag, avg 11µs/call |
| 191 | } | ||||
| 192 | |||||
| 193 | # spent 66.3ms (4.69+61.6) within Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers which was called 73 times, avg 908µs/call:
# 73 times (4.69ms+61.6ms) by Moose::Meta::Role::Application::apply at line 57 of Moose/Meta/Role/Application.pm, avg 908µs/call | ||||
| 194 | 73 | 265µs | my ($self, $role, $class) = @_; | ||
| 195 | 73 | 1.87ms | 73 | 3.46ms | foreach my $method_name ($role->get_method_modifier_list('override')) { # spent 3.46ms making 73 calls to Moose::Meta::Role::get_method_modifier_list, avg 47µs/call |
| 196 | # it if it has one already then ... | ||||
| 197 | 36 | 675µs | 36 | 10.3ms | if ($class->has_method($method_name)) { # spent 10.3ms making 36 calls to Class::MOP::Mixin::HasMethods::has_method, avg 286µs/call |
| 198 | next; | ||||
| 199 | } | ||||
| 200 | else { | ||||
| 201 | # if this is not a role, then we need to | ||||
| 202 | # find the original package of the method | ||||
| 203 | # so that we can tell the class were to | ||||
| 204 | # find the right super() method | ||||
| 205 | 36 | 483µs | 36 | 1.49ms | my $method = $role->get_override_method_modifier($method_name); # spent 1.49ms making 36 calls to Moose::Meta::Role::get_override_method_modifier, avg 41µs/call |
| 206 | 36 | 819µs | 36 | 334µs | my ($package) = Class::MOP::get_code_info($method); # spent 334µs making 36 calls to Class::MOP::get_code_info, avg 9µs/call |
| 207 | # if it is a class, we just add it | ||||
| 208 | 36 | 476µs | 36 | 46.0ms | $class->add_override_method_modifier($method_name, $method, $package); # spent 46.0ms making 36 calls to Moose::Meta::Class::add_override_method_modifier, avg 1.28ms/call |
| 209 | } | ||||
| 210 | } | ||||
| 211 | } | ||||
| 212 | |||||
| 213 | # spent 135ms (10.4+125) within Moose::Meta::Role::Application::ToClass::apply_method_modifiers which was called 219 times, avg 617µs/call:
# 73 times (4.66ms+92.9ms) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 74 of Moose/Meta/Role/Application.pm, avg 1.34ms/call
# 73 times (3.04ms+23.1ms) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 73 of Moose/Meta/Role/Application.pm, avg 358µs/call
# 73 times (2.74ms+8.73ms) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 75 of Moose/Meta/Role/Application.pm, avg 157µs/call | ||||
| 214 | 219 | 847µs | my ($self, $modifier_type, $role, $class) = @_; | ||
| 215 | 219 | 866µs | my $add = "add_${modifier_type}_method_modifier"; | ||
| 216 | 219 | 580µs | my $get = "get_${modifier_type}_method_modifiers"; | ||
| 217 | 219 | 5.13ms | 219 | 9.61ms | foreach my $method_name ($role->get_method_modifier_list($modifier_type)) { # spent 9.61ms making 219 calls to Moose::Meta::Role::get_method_modifier_list, avg 44µs/call |
| 218 | $class->$add( | ||||
| 219 | $method_name, | ||||
| 220 | $_ | ||||
| 221 | 124 | 2.61ms | 124 | 115ms | ) foreach $role->$get($method_name); # spent 87.5ms making 45 calls to Class::MOP::Class::add_around_method_modifier, avg 1.94ms/call
# spent 19.2ms making 11 calls to Class::MOP::Class::add_before_method_modifier, avg 1.75ms/call
# spent 5.35ms making 6 calls to Class::MOP::Class::add_after_method_modifier, avg 892µs/call
# spent 2.24ms making 45 calls to Moose::Meta::Role::get_around_method_modifiers, avg 50µs/call
# spent 509µs making 11 calls to Moose::Meta::Role::get_before_method_modifiers, avg 46µs/call
# spent 266µs making 6 calls to Moose::Meta::Role::get_after_method_modifiers, avg 44µs/call |
| 222 | } | ||||
| 223 | } | ||||
| 224 | |||||
| 225 | 1 | 30µs | 1; | ||
| 226 | |||||
| 227 | __END__ |