| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Role/Application/ToClass.pm |
| Statements | Executed 7702 statements in 116ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 73 | 1 | 1 | 68.9ms | 861ms | Moose::Meta::Role::Application::ToClass::apply_methods |
| 219 | 3 | 1 | 11.0ms | 166ms | Moose::Meta::Role::Application::ToClass::apply_method_modifiers |
| 73 | 1 | 1 | 6.94ms | 1.58s | Moose::Meta::Role::Application::ToClass::apply |
| 73 | 1 | 1 | 5.79ms | 95.5ms | Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers |
| 73 | 1 | 1 | 5.18ms | 274ms | Moose::Meta::Role::Application::ToClass::apply_attributes |
| 73 | 1 | 1 | 4.39ms | 136ms | Moose::Meta::Role::Application::ToClass::check_role_exclusions |
| 73 | 1 | 1 | 3.17ms | 14.1ms | Moose::Meta::Role::Application::ToClass::check_required_methods |
| 73 | 1 | 1 | 549µs | 549µs | Moose::Meta::Role::Application::ToClass::check_required_attributes |
| 1 | 1 | 1 | 97µs | 122µs | Moose::Meta::Role::Application::ToClass::BEGIN@3 |
| 1 | 1 | 1 | 46µs | 298µs | Moose::Meta::Role::Application::ToClass::BEGIN@14 |
| 1 | 1 | 1 | 42µs | 899µs | Moose::Meta::Role::Application::ToClass::BEGIN@7 |
| 1 | 1 | 1 | 42µs | 231µs | Moose::Meta::Role::Application::ToClass::BEGIN@8 |
| 1 | 1 | 1 | 41µs | 111µs | Moose::Meta::Role::Application::ToClass::BEGIN@4 |
| 1 | 1 | 1 | 37µs | 3.04ms | Moose::Meta::Role::Application::ToClass::BEGIN@5 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Role::Application::ToClass; | ||||
| 2 | |||||
| 3 | 3 | 122µs | 2 | 147µs | # spent 122µs (97+25) within Moose::Meta::Role::Application::ToClass::BEGIN@3 which was called:
# once (97µs+25µs) by Moose::BEGIN@31 at line 3 # spent 122µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@3
# spent 25µs making 1 call to strict::import |
| 4 | 3 | 97µs | 2 | 181µs | # spent 111µs (41+70) within Moose::Meta::Role::Application::ToClass::BEGIN@4 which was called:
# once (41µs+70µs) by Moose::BEGIN@31 at line 4 # spent 111µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@4
# spent 70µs making 1 call to warnings::import |
| 5 | 3 | 155µs | 2 | 6.04ms | # spent 3.04ms (37µs+3.00) within Moose::Meta::Role::Application::ToClass::BEGIN@5 which was called:
# once (37µs+3.00ms) by Moose::BEGIN@31 at line 5 # spent 3.04ms making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@5
# spent 3.00ms making 1 call to metaclass::import |
| 6 | |||||
| 7 | 3 | 149µs | 2 | 1.76ms | # spent 899µs (42+857) within Moose::Meta::Role::Application::ToClass::BEGIN@7 which was called:
# once (42µs+857µs) by Moose::BEGIN@31 at line 7 # spent 899µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@7
# spent 857µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756] |
| 8 | 3 | 246µs | 2 | 420µs | # spent 231µs (42+189) within Moose::Meta::Role::Application::ToClass::BEGIN@8 which was called:
# once (42µs+189µs) by Moose::BEGIN@31 at line 8 # spent 231µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@8
# spent 189µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 1 | 6µs | our $VERSION = '1.19'; | ||
| 11 | 1 | 69µs | $VERSION = eval $VERSION; # spent 11µs executing statements in string eval | ||
| 12 | 1 | 3µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 13 | |||||
| 14 | 3 | 3.18ms | 2 | 550µs | # spent 298µs (46+252) within Moose::Meta::Role::Application::ToClass::BEGIN@14 which was called:
# once (46µs+252µs) by Moose::BEGIN@31 at line 14 # spent 298µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@14
# spent 252µs making 1 call to base::import |
| 15 | |||||
| 16 | 1 | 32µs | 2 | 2.23ms | __PACKAGE__->meta->add_attribute('role' => ( # spent 2.09ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 145µs making 1 call to Moose::Meta::Role::Application::ToClass::meta |
| 17 | reader => 'role', | ||||
| 18 | )); | ||||
| 19 | |||||
| 20 | 1 | 24µs | 2 | 2.09ms | __PACKAGE__->meta->add_attribute('class' => ( # spent 2.01ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 84µs making 1 call to Moose::Meta::Role::Application::ToClass::meta |
| 21 | reader => 'class', | ||||
| 22 | )); | ||||
| 23 | |||||
| 24 | # spent 1.58s (6.94ms+1.57) within Moose::Meta::Role::Application::ToClass::apply which was called 73 times, avg 21.6ms/call:
# 73 times (6.94ms+1.57s) by Moose::Meta::Role::apply at line 483 of Moose/Meta/Role.pm, avg 21.6ms/call | ||||
| 25 | 73 | 280µs | my ($self, $role, $class) = @_; | ||
| 26 | |||||
| 27 | # We need weak_ref in CMOP :( | ||||
| 28 | 73 | 1.49ms | 73 | 512µs | weaken($self->{role} = $role); # spent 512µs making 73 calls to Scalar::Util::weaken, avg 7µs/call |
| 29 | 73 | 1.30ms | 73 | 416µs | weaken($self->{class} = $class); # spent 416µs making 73 calls to Scalar::Util::weaken, avg 6µs/call |
| 30 | |||||
| 31 | 73 | 2.07ms | 73 | 1.56s | $self->SUPER::apply($role, $class); # spent 1.56s making 73 calls to Moose::Meta::Role::Application::apply, avg 21.4ms/call |
| 32 | |||||
| 33 | 73 | 985µs | 73 | 5.66ms | $class->add_role($role); # spent 5.66ms making 73 calls to Moose::Meta::Class::add_role, avg 77µs/call |
| 34 | 73 | 1.56ms | 73 | 5.41ms | $class->add_role_application($self); # spent 5.41ms making 73 calls to Moose::Meta::Class::add_role_application, avg 74µs/call |
| 35 | } | ||||
| 36 | |||||
| 37 | # spent 136ms (4.39+132) within Moose::Meta::Role::Application::ToClass::check_role_exclusions which was called 73 times, avg 1.86ms/call:
# 73 times (4.39ms+132ms) by Moose::Meta::Role::Application::apply at line 50 of Moose/Meta/Role/Application.pm, avg 1.86ms/call | ||||
| 38 | 73 | 364µs | my ($self, $role, $class) = @_; | ||
| 39 | 73 | 2.31ms | 146 | 128ms | if ($class->excludes_role($role->name)) { # spent 128ms making 73 calls to Moose::Meta::Class::excludes_role, avg 1.75ms/call
# spent 484µs making 73 calls to Class::MOP::Package::name, avg 7µs/call |
| 40 | $class->throw_error("Conflict detected: " . $class->name . " excludes role '" . $role->name . "'"); | ||||
| 41 | } | ||||
| 42 | 73 | 2.10ms | 73 | 3.15ms | foreach my $excluded_role_name ($role->get_excluded_roles_list) { # spent 3.15ms making 73 calls to Moose::Meta::Role::get_excluded_roles_list, avg 43µ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 14.1ms (3.17+10.9) within Moose::Meta::Role::Application::ToClass::check_required_methods which was called 73 times, avg 193µs/call:
# 73 times (3.17ms+10.9ms) by Moose::Meta::Role::Application::apply at line 51 of Moose/Meta/Role/Application.pm, avg 193µs/call | ||||
| 50 | 73 | 246µs | my ($self, $role, $class) = @_; | ||
| 51 | |||||
| 52 | 73 | 152µs | my @missing; | ||
| 53 | 73 | 130µ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.22ms | 73 | 2.93ms | foreach my $required_method ($role->get_required_method_list) { # spent 2.93ms making 73 calls to Moose::Meta::Role::get_required_method_list, avg 40µs/call |
| 62 | 10 | 141µs | 10 | 154µs | my $required_method_name = $required_method->name; # spent 154µs making 10 calls to Moose::Meta::Role::Method::Required::name, avg 15µs/call |
| 63 | |||||
| 64 | 10 | 214µs | 10 | 7.82ms | if (!$class->find_method_by_name($required_method_name)) { # spent 7.82ms making 10 calls to Class::MOP::Class::find_method_by_name, avg 782µs/call |
| 65 | |||||
| 66 | next if $self->is_aliased_method($required_method_name); | ||||
| 67 | |||||
| 68 | push @missing, $required_method; | ||||
| 69 | } | ||||
| 70 | } | ||||
| 71 | |||||
| 72 | 73 | 991µ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 | 735µs | # spent 549µs within Moose::Meta::Role::Application::ToClass::check_required_attributes which was called 73 times, avg 8µs/call:
# 73 times (549µs+0s) by Moose::Meta::Role::Application::apply at line 52 of Moose/Meta/Role/Application.pm, avg 8µs/call | ||
| 127 | |||||
| 128 | } | ||||
| 129 | |||||
| 130 | # spent 274ms (5.18+269) within Moose::Meta::Role::Application::ToClass::apply_attributes which was called 73 times, avg 3.75ms/call:
# 73 times (5.18ms+269ms) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 3.75ms/call | ||||
| 131 | 73 | 231µs | my ($self, $role, $class) = @_; | ||
| 132 | 73 | 997µs | 73 | 899µs | my $attr_metaclass = $class->attribute_metaclass; # spent 899µs making 73 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 12µs/call |
| 133 | |||||
| 134 | 73 | 1.92ms | 73 | 2.81ms | foreach my $attribute_name ($role->get_attribute_list) { # spent 2.81ms making 73 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 39µs/call |
| 135 | # it if it has one already | ||||
| 136 | 21 | 815µs | 21 | 992µs | if ($class->has_attribute($attribute_name) && # spent 992µs making 21 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 47µ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 | 788µs | 63 | 184ms | $class->add_attribute( # spent 95.7ms making 21 calls to Moose::Meta::Role::Attribute::attribute_for_class, avg 4.56ms/call
# spent 168ms making 21 calls to Moose::Meta::Class::add_attribute, avg 7.98ms/call, recursion: max depth 1, sum of overlapping time 79.9ms
# spent 804µs making 21 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 38µs/call |
| 143 | $role->get_attribute($attribute_name)->attribute_for_class($attr_metaclass) | ||||
| 144 | ); | ||||
| 145 | } | ||||
| 146 | } | ||||
| 147 | } | ||||
| 148 | |||||
| 149 | # spent 861ms (68.9+792) within Moose::Meta::Role::Application::ToClass::apply_methods which was called 73 times, avg 11.8ms/call:
# 73 times (68.9ms+792ms) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 11.8ms/call | ||||
| 150 | 73 | 271µs | my ( $self, $role, $class ) = @_; | ||
| 151 | |||||
| 152 | 73 | 3.97ms | 73 | 206ms | foreach my $method ( $role->_get_local_methods ) { # spent 206ms making 73 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 2.82ms/call |
| 153 | 730 | 14.9ms | 730 | 4.50ms | my $method_name = $method->name; # spent 4.50ms making 730 calls to Class::MOP::Method::name, avg 6µs/call |
| 154 | |||||
| 155 | 730 | 16.6ms | 730 | 7.45ms | next if $method->isa('Class::MOP::Method::Meta'); # spent 7.45ms making 730 calls to UNIVERSAL::isa, avg 10µs/call |
| 156 | |||||
| 157 | 657 | 10.6ms | 657 | 29.4ms | unless ( $self->is_method_excluded($method_name) ) { # spent 29.4ms making 657 calls to Moose::Meta::Role::Application::is_method_excluded, avg 45µs/call |
| 158 | |||||
| 159 | 657 | 7.70ms | 657 | 186ms | my $class_method = $class->get_method($method_name); # spent 186ms making 657 calls to Class::MOP::Mixin::HasMethods::get_method, avg 284µs/call |
| 160 | |||||
| 161 | 657 | 1.24ms | next if $class_method && $class_method->body != $method->body; | ||
| 162 | |||||
| 163 | 657 | 7.88ms | 657 | 330ms | $class->add_method( # spent 330ms making 657 calls to Class::MOP::Mixin::HasMethods::add_method, avg 502µs/call |
| 164 | $method_name, | ||||
| 165 | $method, | ||||
| 166 | ); | ||||
| 167 | } | ||||
| 168 | |||||
| 169 | 657 | 9.63ms | 657 | 27.2ms | next unless $self->is_method_aliased($method_name); # spent 27.2ms making 657 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.61ms | 73 | 892µs | $class->reset_package_cache_flag; # spent 892µs making 73 calls to Class::MOP::Class::reset_package_cache_flag, avg 12µs/call |
| 191 | } | ||||
| 192 | |||||
| 193 | # spent 95.5ms (5.79+89.7) within Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers which was called 73 times, avg 1.31ms/call:
# 73 times (5.79ms+89.7ms) by Moose::Meta::Role::Application::apply at line 57 of Moose/Meta/Role/Application.pm, avg 1.31ms/call | ||||
| 194 | 73 | 276µs | my ($self, $role, $class) = @_; | ||
| 195 | 73 | 1.98ms | 73 | 3.50ms | foreach my $method_name ($role->get_method_modifier_list('override')) { # spent 3.50ms making 73 calls to Moose::Meta::Role::get_method_modifier_list, avg 48µs/call |
| 196 | # it if it has one already then ... | ||||
| 197 | 45 | 1.06ms | 45 | 13.6ms | if ($class->has_method($method_name)) { # spent 13.6ms making 45 calls to Class::MOP::Mixin::HasMethods::has_method, avg 303µ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 | 45 | 666µs | 45 | 1.92ms | my $method = $role->get_override_method_modifier($method_name); # spent 1.92ms making 45 calls to Moose::Meta::Role::get_override_method_modifier, avg 43µs/call |
| 206 | 45 | 1.21ms | 45 | 491µs | my ($package) = Class::MOP::get_code_info($method); # spent 491µs making 45 calls to Class::MOP::get_code_info, avg 11µs/call |
| 207 | # if it is a class, we just add it | ||||
| 208 | 45 | 605µs | 45 | 70.1ms | $class->add_override_method_modifier($method_name, $method, $package); # spent 70.1ms making 45 calls to Moose::Meta::Class::add_override_method_modifier, avg 1.56ms/call |
| 209 | } | ||||
| 210 | } | ||||
| 211 | } | ||||
| 212 | |||||
| 213 | # spent 166ms (11.0+155) within Moose::Meta::Role::Application::ToClass::apply_method_modifiers which was called 219 times, avg 757µs/call:
# 73 times (4.90ms+119ms) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 74 of Moose/Meta/Role/Application.pm, avg 1.69ms/call
# 73 times (3.20ms+26.0ms) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 73 of Moose/Meta/Role/Application.pm, avg 400µs/call
# 73 times (2.89ms+10.3ms) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 75 of Moose/Meta/Role/Application.pm, avg 180µs/call | ||||
| 214 | 219 | 861µs | my ($self, $modifier_type, $role, $class) = @_; | ||
| 215 | 219 | 959µs | my $add = "add_${modifier_type}_method_modifier"; | ||
| 216 | 219 | 664µs | my $get = "get_${modifier_type}_method_modifiers"; | ||
| 217 | 219 | 5.22ms | 219 | 9.28ms | foreach my $method_name ($role->get_method_modifier_list($modifier_type)) { # spent 9.28ms making 219 calls to Moose::Meta::Role::get_method_modifier_list, avg 42µs/call |
| 218 | $class->$add( | ||||
| 219 | $method_name, | ||||
| 220 | $_ | ||||
| 221 | 136 | 3.00ms | 137 | 146ms | ) foreach $role->$get($method_name); # spent 113ms making 52 calls to Class::MOP::Class::add_around_method_modifier, avg 2.18ms/call
# spent 22.4ms making 11 calls to Class::MOP::Class::add_before_method_modifier, avg 2.04ms/call
# spent 6.72ms making 6 calls to Class::MOP::Class::add_after_method_modifier, avg 1.12ms/call
# spent 2.45ms making 51 calls to Moose::Meta::Role::get_around_method_modifiers, avg 48µs/call
# spent 489µs making 11 calls to Moose::Meta::Role::get_before_method_modifiers, avg 44µs/call
# spent 322µs making 6 calls to Moose::Meta::Role::get_after_method_modifiers, avg 54µs/call |
| 222 | } | ||||
| 223 | } | ||||
| 224 | |||||
| 225 | 1 | 32µs | 1; | ||
| 226 | |||||
| 227 | __END__ |